How to stop shitting your pants when seeing a dynamic programming problem

Why would you want to get better with DP?

I have been struggling with DP forever. I just could not get it, so I just start to memorize common DP patterns for technical interviews because it’s not even that common, it shows up only 10% of the time.
One day I was having a mock interview and a DP problem showed up with a pattern that I never saw before, and the interview ended in the first 5 mins. Memorizing patterns makes it binary, it’s either you know the problem and just spet it out (which is not ideal but works), or you don’t know it and here you can not work with the interviewer or do anything, you will just say “I don’t know” and be a big zero.

Why don’t you understand DP?

Simply, because most of the online content is bullshit. if you google any DP problem right now you will probably find a guy filling a table with a pattern that just magically appeared on the whiteboard. But actually, you will never care about filling that table when solving the problem.
if you open LeetCode discussion forms. you will find 5-line-ish solution with a list called “dp” that does not make any sense, you will try to make sense of it but you will fail, but guess what? it’s not supposed to make sense. This is the product, not the process. what you should learn is the process.

Before you learn dynamic programming

Before you learn dynamic programming you must be comfortable with recursion because guess what. DP is recursion. If you can solve the DP problem with a recursive approach you are 95% done with the problem.

Resources

As I said earlier, most of the content in this area is bullshit, so you gotta be careful because a bad resource does not only waste your time, but also confuses you. I would suggest you go for the following resources in order :

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store