Added the solution to the second problem