My Solution

This is my solution for both problems.