Microsoft Interview Question

2 programming exercises, one was very easy to solve, the other was average in difficulty