MathWorks interview question

Oops, optimization and c++ related