MathWorks interview question

Pretty regular leetcode type questions