Google interview question

To solve a coding task.