MathWorks interview question

easy level qns from leetcode