Solution for Problem 2