All guides

Step 3 of 5: Pass the coding test

Dynamic Programming: The Six Shapes

Free

No payment. Just your email.

  • 13 pages
  • 6 shapes
  • Python and Java

About this guide

Dynamic programming taught as six shapes you can recognise instead of theory you cannot use, for a fresher who has been skipping DP. It opens with the two questions that turn any DP problem into code (what is the state, and what choice do I make at each state), then gives one page per shape with the state, the recurrence in words and in code, a verified Python solution, the same lines in Java, and a named example: climbing stairs, house robber, coin change, 0/1 knapsack, longest common subsequence and longest increasing subsequence. Ends with memoisation versus tabulation on the same problem, how to fill and read a DP table by hand, and the five mistakes. Every Python snippet was run and matches the output printed beside it. 13 pages, PDF.

What you download

  • DP_The_Six_Shapes.pdf931 KB