Pergunta de entrevista da empresa MathWorks

Degree question from leetcode : easy problem