Added the solution for Problem 2