Google Interview Question

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