๐ DYNAMIC PROGRAMMING
Dynamic Programming, or DP, is used when a problem can be broken into smaller overlapping subproblems and their results can be reused.
Two important ideas are:
๐ Memoization โ Store results of previously solved states.
๐ Tabulation โ Build results iteratively from smaller states.
DP often appears in problems involving: Sequences, Paths, Knapsack-style problems, Optimization, Counting possibilities
๐ฅ HOW TO RECOGNIZE THE PATTERN
๐น Continuous subarray/substring โ Sliding Window
๐น Sorted data + search โ Binary Search
๐น Pair or opposite-end comparison โ Two Pointers
๐น Need fast lookup โ Hashing
๐น Most recent item first โ Stack
๐น Tree/graph traversal โ BFS / DFS
๐น Explore multiple possibilities โ Backtracking
๐น Repeated subproblems โ Dynamic Programming
๐น Local choices with provable optimality โ Greedy
๐ Double Tap โค๏ธ For More
Post #3909
1.11K
- โค 5