Please help me to solve this problem. I\'ve been trying to solve it using recursion but couldn\'t quite get the expected result. The solution seems to be on the surface but