1. Two Pointer Technique:
2. Sliding Window: [https://www.youtube.com/watch?v=9kdHxplyl5I&list=PLgUwDviBIf0q7vrFA_HEWcqRqMpCXzYAL]
- Constant window - ex max sum in window of size k.
- Longest subarray/ substring where <conditon> - ex longest subarray where sum of element is less than k.
- No of subarrays where <condition> - generally solved using pattern 2 above ; ex - number of subarray with sum equal to k.
3. Fast & Slow Pointer: Used in linked list or array problems, this pattern is ideal for detecting cycles or finding a midpoint.
4. Merge Intervals: Use this pattern to deal with overlapping intervals, helping to create a more organized and efficient structure.
5. Cyclic Sort: Employed when you need to sort numbers within a defined range, it provides a neat way to ensure ordered data.
6. In-place Reversal of a Linked List: If you need to reverse a linked list in-place, this is the pattern to use.
7. Tree Breadth First Search: Perfect for traversing a tree level-by-level, providing a comprehensive overview of all nodes.
8. Tree Depth First Search: This pattern allows you to traverse a tree or graph using depth as the main factor.
9. Two Heaps: Ideal when dealing with situations that require access to both the smallest and largest elements simultaneously.
10. Subset Pattern (Backtracking): Useful in solving problems related to permutations and combinations.
11. Modified Binary Search: An adaptation of the binary search for situations where a standard binary search doesn't apply.
12. Top 'K' Elements: This pattern is beneficial for problems that require identifying the top or bottom 'k' elements in a set.
13. K-way Merge: Employ this pattern to merge K sorted lists or arrays efficiently.
14. 0/1 Knapsack (Dynamic Programming): This dynamic programming pattern is often used for optimization problems.
15. Topological Sort (Graph): Useful in finding a linear ordering of vertices in a directed acyclic graph (DAG).
16. Floyd's Cycle Detection Algorithm: Ideal for finding cycles in data structures such as linked lists or arrays.
17. Kadane’s Algorithm (Dynamic Programming): It's an optimal solution for the maximum subarray problem.
18. Longest Common Subsequence/ Substring (Dynamic Programming): This pattern is handy when finding the longest common subsequence or substring in two strings or arrays.
19. Union Find (Disjoint Set): A data structure used to maintain disjointed sets and is useful for network connectivity problems.
20. Trie (Prefix Tree): Ideal for efficient retrieval of keys in a dataset of strings. It's commonly used for features like autocomplete or spell check.
- Prefix Sum 303. Range Sum Query - Immutable 525. Contiguous Array 560. Subarray Sum Equals K
- Two Pointers 167. Two Sum II - Input Array is Sorted 15. 3 Sum 11. Container with most water
- Sliding Window 643. Maximum Average Subarray I 3. Longest Substring without Repeating Characters 76. Minimum Window Substring
- Fast and Slow Pointers 141. Linked List Cycle 202. Happy Number 287. Find the Duplicate Number
- Linked List in-place reversal 206. Reverse Linked List 92. Reverse Linked List II 24. Swap Nodes in Pairs
- Monotonic Stack 496. Next Greater Element I 739. Daily Temperatures 84. Largest Rectangle in Histogram
- Top K. Elements OR min/max Heap 215. Kth Largest element in an array 347. Top K Frequent Elements 373. Find K Pairs with Smallest Sums
- Overlapping Intervals 56. Merge Intervals 57. Insert Interval 435. Non-overlapping intervals
- Modified Binary Search 33. Search in Rotated Sorted Array 153. Find Minimum in Rotated Sorted Array 240. Search a 2D Matrix II
- Binary Tree Traversal 257. Binary Tree Paths 230. Kth Smallest Element in a BST 124. Binary Tree Maximum Path Sum 107. Binary Tree Level Order Traversal II
- Depth First Search 133. Clone Graph 113. Path Sum II 210. Course Schedule II
- Breadth First Search 102. Binary Tree Level Order Traversal 994. Rotting Oranges 127. Word Ladder
- Matrix Traversal 733. Flood Fill 200. Number of Islands 130. Surrounded Regions
- Backtracking 46. Permutations 78. Subsets 51. N-Queens
- Dynamic Programming 70. Climbing Stairs 322. Coin Change 300. Longest Increasing Subsequence 416. Partition Equal Subset Sum 312. Burst Balloons 1143. Longest Common Subsequence