Skip to main content

β˜• LeetCode Study Guide

A structured approach to mastering algorithms and data structures for coding interviews β€” with 530+ solved problems across 17 categories.

How to Use This Guide
  1. Follow the 8-week roadmap below from Phase 1 β†’ Phase 4
  2. For each topic, read the pattern explanation first
  3. Solve problems in order of difficulty (Easy β†’ Medium β†’ Hard)
  4. Review your solutions and compare with the ones here
  5. Use the Pattern Cheat Sheet below when you're stuck

Roadmap Overview​


Study Plan by Category​

Phase 1: Fundamentals (Weeks 1-2)​

Goal: Build a strong foundation with arrays, strings, and basic techniques.

PatternKey ProblemsWhat You'll Learn
ArraysTwo Sum, Contains Duplicate, Merge Sorted ArrayArray manipulation, hash maps
StringsValid Anagram, Longest Substring, Group AnagramsString processing, frequency counting
Two Pointers3Sum, Container With Most Water, Remove DuplicatesConverging and diverging pointers
Sliding WindowMax Subarray, Min Window SubstringVariable and fixed-size windows

Phase 2: Core Data Structures (Weeks 3-4)​

Goal: Master linked lists, stacks, and search techniques.

PatternKey ProblemsWhat You'll Learn
Linked ListsReverse List, Merge Two Lists, Detect CyclePointer manipulation, fast/slow
StacksValid Parentheses, Min Stack, Daily TemperaturesLIFO processing, monotonic stacks
Binary SearchSearch in Rotated Array, Find Peak Element$O(\log n)$ search, boundary finding
SortingMerge Sort, Quick Sort, Sort ColorsDivide and conquer, partitioning

Phase 3: Trees and Graphs (Weeks 5-6)​

Goal: Conquer tree traversals, graph algorithms, and grid problems.

PatternKey ProblemsWhat You'll Learn
Binary TreesInorder/Level-Order Traversal, Max DepthDFS, BFS, recursion
BSTValidate BST, Kth Smallest, LCABST properties, in-order traversal
GraphsNumber of Islands, Clone Graph, Course ScheduleBFS/DFS, topological sort
Matrix01 Matrix, Rotting Oranges, Spiral MatrixGrid BFS/DFS, direction arrays

Phase 4: Advanced Patterns (Weeks 7-8)​

Goal: Tackle the hardest patterns β€” DP, backtracking, and optimization.

PatternKey ProblemsWhat You'll Learn
Dynamic ProgrammingCoin Change, LIS, House Robber, Edit DistanceState definition, transitions
BacktrackingSubsets, Permutations, N-QueensExplore and backtrack, pruning
GreedyJump Game, Task Scheduler, Meeting RoomsLocal to global optimal
Bit ManipulationSingle Number, Counting Bits, Power of TwoXOR tricks, bit masks

Key Patterns Cheat Sheet​

When to Use What​

Quick Pattern Recognition​

If you see...Think...Example
"Find pair/triplet with sum"Two Pointers (sort first)3Sum, Two Sum II
"Longest/shortest substring"Sliding WindowMin Window Substring
"Find in sorted array"Binary SearchSearch Rotated Array
"All combinations/permutations"BacktrackingSubsets, Permutations
"Min/Max cost, # of ways"Dynamic ProgrammingCoin Change
"Connected components"BFS/DFS or Union-FindNumber of Islands
"Level-by-level"BFSLevel-Order Traversal
"Next greater/smaller"Monotonic StackDaily Temperatures
"Top K elements"HeapKth Largest Element
"Prefix lookup"TrieImplement Trie

Time Complexity Quick Reference​

AlgorithmBestAverageWorstSpace
Binary Search$O(1)$$O(\log n)$$O(\log n)$$O(1)$
Two Pointers$O(n)$$O(n)$$O(n)$$O(1)$
Sliding Window$O(n)$$O(n)$$O(n)$$O(k)$
BFS/DFS$O(V+E)$$O(V+E)$$O(V+E)$$O(V)$
Merge Sort$O(n \log n)$$O(n \log n)$$O(n \log n)$$O(n)$
Quick Sort$O(n \log n)$$O(n \log n)$$O(n^2)$$O(\log n)$
Heap Push/Pop-$O(\log n)$$O(\log n)$$O(n)$
Hash Table$O(1)$$O(1)$$O(n)$$O(n)$
Trie Insert/Search-$O(L)$$O(L)$$O(n \times L)$
Union-Find-$O(\alpha(n))$$O(\alpha(n))$$O(n)$

Interview Tips​

5-Step Framework for Any Problem
  1. Clarify β€” Ask about constraints, edge cases, input size, duplicates
  2. Brute Force β€” Start with the simplest solution, clearly state its complexity
  3. Optimize β€” Identify the bottleneck, consider which pattern applies
  4. Code β€” Write clean, readable code with meaningful variable names
  5. Test β€” Walk through examples, then check edge cases
Common Edge Cases to Always Check
  • Empty input / single element
  • All duplicates / all same values
  • Already sorted / reverse sorted
  • Negative numbers / zero
  • Integer overflow ($2^{31} - 1$)
  • Null nodes in trees / empty lists
  • Disconnected components in graphs
Common Mistakes in Interviews
  • Starting to code without discussing the approach first
  • Not considering edge cases until asked
  • Using global variables when recursion exists
  • Off-by-one errors in binary search
  • Not handling the base case in DP
  • Forgetting to mark nodes as visited in BFS/DFS

Browse All Categories​

Explore 530+ problems organized by topic. Each page includes the problem statement, solution code in C#, complexity analysis, and pattern explanations.

CategoryProblemsFocus Areas
πŸ“Š Arrays45Two pointers, sliding window, binary search, prefix sums
🌳 Trees97DFS, BFS, BST, tree construction, path problems
πŸ”€ Strings54Pattern matching, palindromes, anagrams, parsing
🧩 Dynamic Programming381D/2D DP, knapsack, subsequences, intervals
πŸ”— Linked Lists26Reversal, merge, cycle detection, fast/slow pointers
πŸ”’ Math25Number theory, geometry, combinatorics
πŸ—„οΈ SQL23Joins, aggregations, window functions, subqueries
πŸ“ˆ Sorting21Comparison sorts, counting sort, custom comparators
πŸ”™ Backtracking16Subsets, permutations, constraint satisfaction
⬜ Matrix16Grid BFS/DFS, rotation, spiral traversal
πŸ’Ύ Bit Manipulation15XOR, bit counting, masks, power of two
πŸ•ΈοΈ Graphs11BFS, DFS, topological sort, union-find, shortest path
🎯 Greedy9Interval scheduling, activity selection
πŸ“š Stack9Monotonic stack, expression evaluation, brackets
πŸ—οΈ Design7LRU/LFU cache, iterators, data structure design
🌲 Trie3Prefix matching, autocomplete, word search
πŸ’» LeetCode (Misc)112Mix of patterns and categories