Tilling problem?can someone please tell me what i am doing wrong

@sarthaksingh you are doing nothing wrong. The recursive approach that you used if 100% correct. But the thing is, the answer expected of you is the one which includes dynamic programming. I believe, you must be getting Time limit exceeded error.
If you have not covered Dynamic Programming then I’d suggest you to hold on this question for some time.