Welcome to the LeetCode Solutions & Algorithm Knowledge Base. This repository serves as a systematic, high-performance vault of solved LeetCode problems (primarily in modern C++), paired with comprehensive theory notes, pattern guides, complexity breakdowns, and an automated master index.
- 📑 Master Problem Index: Searchable table of all solved problems with complexity stats, direct links to solutions, and topic notes.
- 🤖 Agent Guidelines (AGENTS.md): Complete automation rules, C++ template specifications, and update procedures for AI assistants.
- 📂 Solutions Directory: Organized by
<problem_id>-<slug>containing code (solution.cpp) and intuition (README.md). - 📚 Topics Directory: Curated theory, algorithms, patterns, and cheat-sheets for all major DSA categories.
| Total Solved | 🟢 Easy | 🟡 Medium | 🔴 Hard |
|---|---|---|---|
| 204 | 3 | 1 | 200 |
| Topic | Key Concepts | Solved Count | Link |
|---|---|---|---|
| :--- | :--- | :---: | :--- |
| Arrays & Hashing | Hash Maps, Hash Sets, Prefix Sums, Kadane's | 14 | Explore Notes |
| Two Pointers | Opposite Ends, Same Direction, Partitioning | 2 | Explore Notes |
| Sliding Window | Fixed Window, Dynamic Window, Monotonic Queue | 8 | Explore Notes |
| Stack & Queue | Monotonic Stack, Parentheses, Min-Stack, Queues | 10 | Explore Notes |
| Binary Search | Classic BS, Search on Answer, Rotated Arrays | 14 | Explore Notes |
| Linked List | Fast & Slow Pointers, Reversals, Dummy Nodes | 4 | Explore Notes |
| Trees & BST | Traversals, LCA, BST properties, Segment Trees | 8 | Explore Notes |
| Heaps / Priority Queue | Top-K Elements, Two Heaps Pattern, Merge K Lists | 9 | Explore Notes |
| Backtracking | Permutations, Combinations, Subsets, Pruning | 10 | Explore Notes |
| Graphs | BFS/DFS, Dijkstra, Topo Sort, Union-Find, Bellman-Ford | 14 | Explore Notes |
| Dynamic Programming | 1D/2D DP, State Compression, Memoization | 43 | Explore Notes |
| Greedy | Activity Selection, Jump Game, Huffman Coding | 13 | Explore Notes |
| Intervals | Merging Intervals, Insert Intervals, Overlap Checks | 4 | Explore Notes |
| Bit Manipulation | XOR properties, Bitmasks, Power of 2 checks | 3 | Explore Notes |
| Math & Geometry | Modular Arithmetic, Number Theory, Geometry | 30 | Explore Notes |
All solutions are written in standard C++17/20 and include built-in test runners in main() with assertions guarded by #ifdef LOCAL_TEST:
# Compile locally with g++
g++ -std=c++17 -DLOCAL_TEST -O2 -Wall solutions/<id>-<slug>/solution.cpp -o solution.exe
# Run test cases
./solution.exeOr on Linux / macOS / WSL:
clang++ -std=c++20 -DLOCAL_TEST -O2 -Wall solutions/<id>-<slug>/solution.cpp -o solution.out
./solution.outTip
You can safely copy and paste the entire solution.cpp file directly into LeetCode. Because main() is wrapped in #ifdef LOCAL_TEST, LeetCode's compiler will only execute class Solution without conflicting with LeetCode's internal test runner.