MathWorks Interview Question

Degree question from leetcode : easy problem