1
$\begingroup$

I've been able to form a recurrence relation with memoization in a recursive approach for most problems but the online coding rounds exceed the time limit or stack overflow occurs in all these problems. An iterative approach seems to be the only way out. But coming up with logic for filling the DP table is frustrating and difficult. Are there steps with which we can convert any recurrence relation into a DP table calculation?

asked Aug 11, 2021 at 17:48
$\endgroup$

1 Answer 1

2
$\begingroup$
  • Analyse the problem and find out which values you have to compute and how they depend on each other.
  • Make a table that can hold these values with somewhat intuitive indices, and fill it in an order that is easy to follow, but doesn't conflict with the dependencies.

I'm afraid it's hard to be any more specific here, as the values, their enumeration and the dependencies between them, all vary widely between problems.

answered Aug 12, 2021 at 7:28
$\endgroup$

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.