Google interview question

An algorithm problem to solve