Hub for #data-structures-and-algorithms
Arrays and Hashing
| Name | Brief | Updated | Tags |
|---|---|---|---|
| Counters | Counting contents of an array | note, data-structures, arrays-and-hashing | |
| Map Lookups | Using a map to find an item in an array | note, data-structures, arrays-and-hashing | |
| Prefix Postfix | Trick to track partial Summation answers | note, data-structures, arrays-and-hashing |
Stack
| Name | Brief | Updated | Tags |
|---|---|---|---|
| LIFO Stack | last in first out | note, data-structures, stack | |
| Monotonic Stack | Always increasing/decreasing stack | note, stack, data-structures |
Two Pointer
| Name | Brief | Updated | Tags |
|---|---|---|---|
| Two Pointer Converging | For when you are looking for a pair/target | note, data-structures, two-pointer |
Binary Search
| Name | Brief | Updated | Tags |
|---|---|---|---|
| Binary Search Exact | Finding value in sorted array | note, data-structures, binary-search | |
| Bisect Left-Right | Find leftmost or rightmost value in range | note, binary-search, data-structures | |
| Bisect Range | Find the range of values | note, binary-search, data-structures | |
| Predicate Search | TODO | note, binary-search |
Sliding Window
| Name | Brief | Updated | Tags |
|---|---|---|---|
| Fixed Sliding Window | For fixed size problems | note, data-structures, sliding-window | |
| Variable Sliding Window | For finding a range that fulfills a condition | note, sliding-window |
Trees
| Name | Brief | Updated | Tags |
|---|---|---|---|
| Backtracking | Choose, explore, undo — DFS over partial solutions with pruning | note, data-structures, trees | |
| Binary Search Tree (BST) Bisect Left-Right | Closest value (floor/ceiling) in a BST by walking the tree | note, trees, data-structures | |
| Binary Search Tree (BST) Search Exact | Tree where left <= node <= right | note, data-structures, trees | |
| Inorder traversal | Left → node → right; | note, data-structures, trees | |
| Postorder traversal | Left → right → node; | note, data-structures, trees | |
| Preorder traversal | Node → left → right; | note, data-structures, trees | |
| Trie | Structure for text lookup | note, trees, data-structures |
Linked List
| Name | Brief | Updated | Tags |
|---|---|---|---|
| Floyd's Cycle Detection | For finding cycles and their start. | note, linked-list, data-structures | |
| Gap Method | Sliding window for linked lists | note, data-structures, linked-list | |
| Reverse Linked List | To reverse a node next node string | note, data-structures, linked-list |
Heap
| Name | Brief | Updated | Tags |
|---|---|---|---|
| Heap | Min/max always on top | note, heap, data-structures | |
| Two heap | For keeping a running median | note, heap, data-structures |
Graph
| Name | Brief | Updated | Tags |
|---|---|---|---|
| Adjacency List | Graph+Map+Neighbors | note, graphs, data-structures | |
| Breadth First Search | Checks each level before the next | note, data-structures, graphs | |
| Depth First Search | Path traversal | note, graphs, data-structures | |
| Dijkstra's Algorithm | Shortest distance algo | note, data-structures, graphs |
Dynamic Programming
| Name | Brief | Updated | Tags |
|---|---|---|---|
| Bottom up DP | Table based DP | note, data-structures, dp | |
| Top down DP | Recursion based DP | note, data-structures, dp |
Greedy
| Name | Brief | Updated | Tags |
|---|---|---|---|
| Kadane's Algorithm | Max-sum contiguous subarray in O(n) | note, greedy, data-structures |
Math
| Name | Brief | Updated | Tags |
|---|---|---|---|
| Index digit in number | Get the i-th digit of an int without strings | note, data-structures, math | |
| Integer length | Count digits of an int without strings | note, data-structures, math | |
| K Nearest Neighbors | Nearest in XY plot | note, machine-learning, math, data-structures |
State Machine
| Name | Brief | Updated | Tags |
|---|---|---|---|
| State Machine | FSM | note, state-machine, data-structures |
Sort
| Name | Brief | Updated | Tags |
|---|---|---|---|
| Quick Sort | note, data-structures, data-structures-and-algorithms, sort |
Resources
- Practice process: Solving a Leetcode Problem.
- leetcode flashcards