Google interview question

Leetcode Med/Hard questions, pretty straightforward