Domanda di colloquio di MathWorks

Degree question from leetcode : easy problem