Google Interview Question

Previous challenge and how I solved