MathWorks Interview Question

coding like leetcode. c++ knowledge