Cheatography
https://cheatography.com
Choosing the right technique or algorithm to solve a problem often depends on recognizing certain patterns or key characteristics in the problem statement.
This is a draft cheat sheet. It is a work in progress and is not finished yet.
Greedy Algorithms
Indicator |
Making locally optimal choices to find a global optimum, problems involving finding minimum/maximum values. |
Tips |
Prove the greedy choice property and ensure it leads to an optimal solution. |
Common Patterns |
Interval scheduling, activity selection, minimum spanning trees. |
Examples |
Activity Selection Huffman Coding Dijkstra's Algorithm |
|
Dynamic Programming (DP)
Indicators |
Optimal substructure, overlapping subproblems, constraints involving maximum/minimum values, finding number of ways to achieve a target. |
Tips |
Use memoization or tabulation to store results of subproblems, break the problem into smaller subproblems. |
Common Patterns |
Subset sums, longest subsequences, edit distance. |
Examples |
Longest Common Subsequence ,Knapsack Problem, Coin Change Problem |
|