adding solution for 4th  problem