MathWorks interview question

Technical interview was a leetcode hard backtracking