add solution for the third problem