Google Interview Question

A medium to easy Leet-code style question