-
Notifications
You must be signed in to change notification settings - Fork 3
Patterns to master
Girish Prabhu edited this page Oct 6, 2020
·
7 revisions
Here are a few patterns to master
- Sliding Window
- Binary Search Patterns
- find exact match
- find closest match
- find starting index|first occurrance (left bound)
- find ending index|last occurrance (right bound)
- find number of occurrences
- unidirectional binary search (increments in pow of 2 which max idx is unknown)
- Find in rotated sorted array
- Using Min/Max Heap
- Graph Traversals (DFS, BFS, Topological Sort, Dijkstra's)
- Min Distance (with/without k hops) (BFS)
- Min Cost (Dijkstras)
- Reachability (DFS)
- Ordering (Topological Sort)
- BST and Binary Tree (Inorder, Pre/Post, BFS/DFS, height/diameter, Balanced)
- Arrays (prefix sums, left/right pointers)
- Strings (palindromes, BFS/DFS, pattern matching - Rolling Hash/KMP)
- Trie
- Union Find
- Dynamic Programming
- Kadane's Algorithm
- Monotonic queues
- Quick select (Alternative to heap sort for kth element)
- Fenwick Tree
- Segment Tree and Interval Tree