Please check the code

https://ide.codingblocks.com/#/s/13876
https://hack.codingblocks.com/contests/c/452/1267
running for sample test cases but tle for real test cases

Hello Harshit ! , actually there are lots of errors in ur code . Lke you made Dp array inside a recursive function and calling this again and again and expecting that answer to particular m and n and o gets saved. But whenever you are calling next call your saved values of present dp will not be going to use in further call , so you need to declare it as global array. If you still have difficulty then go through this https://ide.codingblocks.com/#/s/13989

1 Like