Google interview question

Two LeetCode medium questions, both focused on arrays.