Solution for the 4th problem
Solution for the fifth problem