wrote the solution for first problem