Unable to clear a testcase

can we solve it using recursion like this?

hi @goyalvivek, yes, try this correction and confirm coz im not getting this question exactly in backend… https://ide.codingblocks.com/s/667285, also if this gives TLE u can use dp for that