MathWorks interview question

dp question using 2 arrays