A structured repository of C++ data structures and algorithmic problem solutions, organized around core problem-solving patterns rather than ad-hoc solutions.
- Two Pointers / Scanning: Reducing search space through sorted properties and symmetric scans (e.g., 3Sum, Valid Palindrome, Reverse String).
- Hashing & Frequency Mapping: O(1) lookups, grouping, and frequency counters (e.g., Two Sum, Group Anagrams, Contains Duplicate).
- Heaps & Priority Queues: Top-K element tracking with optimal O(N log K) time complexity.
- Tree Traversals: Depth-First Search (DFS) & Breadth-First Search (BFS) using recursion, queues, and iterative traversal.
- Dynamic Programming: Building a solution from smaller overlapping subproblems and compressing state when only recent values are required (e.g., Climbing Stairs).
- Greedy / Running State: Maintaining the best state seen so far for one-pass optimization problems (e.g., Best Time to Buy and Sell Stock).
| # | Problem | Pattern / Technique | Time | Space | Directory |
|---|---|---|---|---|---|
| 1 | Two Sum | Hash Map / Complement Lookup | O(N) avg. | O(N) | 0001-two-sum/ |
| 15 | 3Sum | Sorting + Two Pointers | O(N^2) | O(1) | 15-3sum/ |
| 49 | Group Anagrams | Hash Map (Sorted Key / Count) | O(N · K log K) | O(N · K) | 49-group-anagrams/ |
| 70 | Climbing Stairs | Dynamic Programming / State Compression | O(N) | O(1) | 0070-climbing-stairs/ |
| 102 | Binary Tree Level Order Traversal | Breadth-First Search / Queue | O(N) | O(W) | 0102-binary-tree-level-order-traversal/ |
| 104 | Maximum Depth of Binary Tree | Tree DFS / Recursion | O(N) | O(H) | 0104-maximum-depth-of-binary-tree/ |
| 121 | Best Time to Buy and Sell Stock | Greedy / Running Minimum | O(N) | O(1) | 0121-best-time-to-buy-and-sell-stock/ |
| 125 | Valid Palindrome | Two Pointers | O(N) | O(1) | 125-valid-palindrome/ |
| 217 | Contains Duplicate | Hash Set | O(N) | O(N) | 217-contains-duplicate/ |
| 242 | Valid Anagram | Frequency Array / Hash Table | O(N) | O(1) | 0242-valid-anagram/ |
| 344 | Reverse String | Two Pointers / In-Place Swap | O(N) | O(1) | 0344-reverse-string/ |
| 347 | Top K Frequent Elements | Min-Heap / Bucket Sort | O(N log K) | O(N) | 347-top-k-frequent-elements/ |
| 1470 | Shuffle the Array | Array Interleaving | O(N) | O(1) | 1580-shuffle-the-array/ |
| 1971 | Find if Path Exists in Graph | Graph DFS / Adjacency List | O(N + E) | O(N + E) | 1971-find-if-path-exists-in-graph/ |
| Day | Date | Problem | Pattern |
|---|---|---|---|
| 1 | 2026-09-18 | 104. Maximum Depth of Binary Tree | Tree DFS |
| 2 | 2026-09-19 | 70. Climbing Stairs | Dynamic Programming |
| 3 | 2026-09-20 | 102. Binary Tree Level Order Traversal | Tree BFS |
| 4 | 2026-09-21 | 1971. Find if Path Exists in Graph | Graph DFS |
| 5 | 2026-09-22 | 121. Best Time to Buy and Sell Stock | Greedy / Running Minimum |
| 6 | 2026-09-26 | 1. Two Sum | Hash Map |
| 7 | 2026-09-30 | 344. Reverse String | Two Pointers |
Compile the solution with g++ or clang++ using C++17 or newer.
Example: g++ -std=c++17 -O2 0344-reverse-string/reverse-string.cpp -o solution
MIT License.