Google Interview Question

2 array questions and 1 DP problem with sub parts.