MathWorks Interview Question

Medium Leetcode Question for Tech phone screen