This repository is my living DSA notebook — a continuously updated log of optimized solutions to LeetCode problems. Every solution here is:
- ✅ Accepted on LeetCode (verified submission)
- ⚡ Optimized for both time and space complexity
- 📝 Documented with approach explanation and complexity analysis
- 🏷️ Tagged by topic, difficulty, and pattern
| # | Topic | Key Patterns |
|---|---|---|
| 1 | 📦 Arrays | Prefix Sum, Kadane's, Sorting |
| 2 | 🔤 Strings | Sliding Window, Two Pointers, KMP |
| 3 | 🔗 Linked Lists | Fast & Slow Pointers, Reversal |
| 4 | 🌳 Trees & BST | BFS, DFS, In/Pre/Post-order |
| 5 | 🕸️ Graphs | DFS, BFS, Union-Find, Dijkstra |
| 6 | 💡 Dynamic Programming | Top-Down, Bottom-Up, Memoization |
| 7 | 🔙 Backtracking | Permutations, Subsets, N-Queens |
| 8 | 🔍 Binary Search | Search Space Reduction, Rotated Arrays |
| 9 | 📊 Heaps & Priority Queues | Top-K, Merge K Sorted |
| 10 | 📚 Stacks & Queues | Monotonic Stack, BFS Queue |
| 11 | 🪟 Sliding Window | Fixed & Variable Window |
| 12 | 👆 Two Pointers | Opposite Ends, Same Direction |
| 13 | 💰 Greedy | Interval Scheduling, Huffman |
| 14 | 🔢 Math & Bit Manipulation | XOR, Bit Counting, Modular |
git clone https://github.com/Ayush-2703/LeetCode_Problems.git
cd LeetCode_ProblemsEvery solution in this repo is evaluated against three tiers before being committed:
Tier 1 — Correctness → Does it pass all LeetCode test cases?
Tier 2 — Complexity → Is Big-O time and space optimal or near-optimal?
Tier 3 — Readability → Is it clean enough to explain in a 45-minute interview?
📌 Click to expand — Pattern Cheatsheet
| Pattern | When to Use | Example Problems |
|---|---|---|
| Two Pointers | Sorted arrays, palindromes, pair sums | 3Sum, Container With Most Water |
| Sliding Window | Contiguous subarray/substring problems | Longest Substring, Min Window Substring |
| Fast & Slow Pointers | Cycle detection, middle of linked list | Linked List Cycle, Happy Number |
| Merge Intervals | Overlapping ranges | Merge Intervals, Insert Interval |
| Cyclic Sort | Problems involving 1→N range arrays | Missing Number, Find All Duplicates |
| In-place Reversal (LL) | Reversing without extra space | Reverse LL, Reverse Sublist |
| Tree BFS | Level-order traversal, shortest path | Level Order Traversal, Right Side View |
| Tree DFS | Path sums, max depth, subtree checks | Path Sum, Lowest Common Ancestor |
| Two Heaps | Median of stream, task scheduling | Find Median from Data Stream |
| Subsets / Backtracking | Generating combinations/permutations | Subsets, Permutations, Combination Sum |
| Binary Search | Sorted arrays, search space reduction | Search in Rotated Array, Koko Eating Bananas |
| Top K Elements | Kth largest/smallest, frequent elements | Top K Frequent, Kth Largest in Stream |
| K-way Merge | Merging K sorted arrays/lists | Merge K Sorted Lists, Smallest Range |
| Monotonic Stack | Next greater/smaller element | Daily Temperatures, Largest Rectangle |
| DP — Knapsack | Subset sums, capacity constraints | 0/1 Knapsack, Coin Change |
| DP — LCS/LIS | Subsequence problems | LCS, LIS, Edit Distance |
| Graph — Union Find | Connectivity, cycle detection | Number of Provinces, Redundant Connection |
| Graph — Topological Sort | Dependencies, ordering | Course Schedule, Alien Dictionary |
This repository is licensed under the MIT License.
Solutions are for learning and reference purposes only. Please attempt problems independently before viewing solutions.
Maintained by Ayush Kumar Singh
