Microsoft interview question

The programming question because time was running out.