MathWorks Interview Question

easy level qns from leetcode