Add solution to problem2.