IBM interview question

Programming on Whiteboard