← Back to context

Comment by joz1-k

9 hours ago

> Read wikipedia and it seems to mean....use a recursive function?

Yes, that's one (common) approach to dynamic programming. The recursive function call are memoized so that previous calculations are remembered for future function calls. Overlapping subproblems become trivial if you can reuse previously computed values. The recursion with memoization is top-down dynamic programming.

So all in all pretty basic stuff. Why would anyone worth their salt should have problem with that?

  • The hard part is realizing that the problem you're solving efficiently maps to a dynamic programming algorithm. You have to spot the opportunity for sub-problem reuse, or else the solution looks something like cubic or exponential (etc.)