Study Plan: Dynamic Programming

3 minute read

Published:

This page is continually updated with new and improved content to ensure the best curation for Dynamic Programming problems.

Pattern 1: 0/1 Knapsack (Bounded)

Solution is built upon subset, but with few more restrictions. For example you want to complete some courses, they have some reward points associated. But you can attend only k number of courses. Now try to maximize your points. This type of problems are just an extension to simple DP, where you add one more dimension to consider provided restriction.

Problems:

Pattern 2: 0/1 Knapsack (Unbounded)

Dp state is similar to the classical knapsack problem.

Problems:

Pattern 3: Fibonacci (or Linear DP)

You just need to find the repetitive part of the solution and improve it by saving its result.

Dp solution requires us to solve the sub problem on every prefix of the array. A prefix of the array is a subarray from 0 to i for some i.

Problems:

Pattern 4: String DP

Problems:

Pattern 5: Longest Common Subsequence (LCS) [String DP]

Problems:

Pattern 6: Palindromes (LCS)

Problems:

Pattern 7: Longest Increasing Subsequence (LIS)

Dp problem is solved on every prefix of the array. Transition is from every index j < i.

Problems:

Pattern 8: Matrix Chain Multiplication

Dp problem is solved on every single interval (subarray) of the array.

Problems:

Pattern 9: Kadane’s Algorithm

Problems:

Pattern 10: DP on Trees

Problems:

Pattern 11: Grid DP

Dp table will have the same dimensions as grid, the state at cell i,j will be related to the grid at cell i,j.

Problems:

Pattern 12: DP + Bitmask

Problems:

Pattern 13: Graph DP

Problems: