Adding solution for problem 1