Testcase 1 , 3,4,5 timelimit reached.
code with dynamic approach - https://ide.codingblocks.com/s/161358
recursive program - https://ide.codingblocks.com/s/161359
Let me know if there’s problem with the dynamic approach or perhaps with the recursive approach itself.