Google interview question

Nothing too difficult to work out. Discuss with your interviewer before you code.