Pregunta de entrevista de MathWorks

Degree question from leetcode : easy problem