Google Interview Question

array problem and dynamic programming problem