Difficulty in converting recursive solution to memoization / top-down DP

Revision en2, by MoonKnight9031, 2022-01-27 08:24:58

In some Dynamic Programming Problems, I am able to code the recursive solution but I find it hard to convert it into Top-Down DP or Memoization. For example :- This is a problem from yesterday's Codechef Starters Contest:- Problem Link

Below is my Recursive Code to the problem:-

My Code

It would be helpful if someone could suggest me some ideas on how to do so.

Tags help, dynamic programming, backtracking, recursion

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English MoonKnight9031 2022-01-27 08:24:58 78 (published)
en1 English MoonKnight9031 2022-01-27 08:21:14 1721 Initial revision (saved to drafts)