Google interview question

Previous challenge and how I solved