Google interview question

2 array questions and 1 DP problem with sub parts.