MathWorks Interview Question

dp question using 2 arrays