Google interview question

A medium to easy Leet-code style question