MathWorks interview question

Degree question from leetcode : easy problem