Skip to content

Comprehensive LeetCode study guide featuring 1500+ problems systematically organized across 71 topics. Includes foundation concepts, common patterns, edge cases, company-specific prep, and progress tracking.

License

Notifications You must be signed in to change notification settings

abhisheksrocks/dsa-roadmap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

COMPREHENSIVE LEETCODE MASTERY PLAN

A structured learning path covering all 71 LeetCode topics with 1500+ problems organized by concepts, patterns, and difficulty levels. This plan emphasizes deep understanding over speed, with problems carefully sequenced to build upon previous knowledge. Each topic includes foundation problems, common patterns, edge cases, and synthesis exercises to ensure complete mastery.

PHASE 1: FUNDAMENTALS

Topic 1: Arrays

Foundation & Basic Operations
Basic Array Manipulation:
Two Pointers Pattern
Basic Two Pointers:
Advanced Two Pointers:
Prefix Sum
Basic Matrix

Topic 2: Strings

Foundation
Basic String Operations:
String Building:
Character Counting & Frequency
Pattern Matching

Topic 3: Basic Math

Arithmetic Operations
Number Theory Basics
Counting & Statistics

Topic 4: Basic Bit Manipulation

Bit Operations

Topic 5: Binary Search

Classic Binary Search
Binary Search Applications

Topic 6: Hash Tables

Foundation
Frequency Counting
Set Operations

Topic 7: Basic Recursion

Foundation

Topic 8: Sorting Fundamentals

Basic Sorting

PHASE 2: DATA STRUCTURES

Topic 9: Linked Lists

Foundation
Basic Operations:
Two Pointers in Linked Lists
Fast & Slow Pointers:
Advanced Two Pointers:
Advanced Operations
Complex Problems

Topic 10: Stacks

Stack Foundation
Stack Design
Expression Evaluation
Monotonic Stack
Next Greater/Smaller:
Advanced Monotonic Stack:

Topic 11: Queues

Queue Foundation
Queue Design

Topic 12: Trees - Fundamentals

Binary Tree Basics
Tree Traversal:
Tree Properties:
Binary Search Trees (BST)
BST Basics:
Path Problems
N-ary Trees

Topic 13: Heaps (Priority Queue) - Basics

Heap Foundation
Top K Problems - Basic

PHASE 3: ALGORITHMS

Topic 14: Sliding Window

Fixed Window
Variable Window
Advanced Sliding Window

Topic 15: Greedy Algorithms

Basic Greedy
Interval Scheduling
Advanced Greedy

Topic 16: Backtracking

Subsets & Combinations
Permutations
String Generation
Grid & Board Problems
Advanced Backtracking

Topic 17: Dynamic Programming

1D DP - Basic
1D DP - Sequences
Stock Trading
2D DP - Grid
String DP
Knapsack Problems
Advanced DP

Topic 18: Graph Algorithms - BFS & DFS

Basic Graph Traversal
BFS Fundamentals:
DFS Fundamentals:
Connected Components
BFS Applications
Shortest Path (Unweighted):
Multi-source BFS:
DFS Applications
Cycle Detection:
Path Finding:
Topological Sort
Bipartite Graphs

PHASE 4: ADVANCED DATA STRUCTURES

Topic 19: Advanced Trees

Tree Construction & Serialization
Advanced BST Operations
Tree Views & Special Traversals
Lowest Common Ancestor
Advanced Tree Problems
Path Sum Advanced

Topic 20: Advanced Heap (Priority Queue)

Top K Problems - Advanced
Merge K Sorted
Two Heaps Pattern
Task Scheduling
Complex Heap Problems

Topic 21: Trie

Trie Implementation
Word Search with Trie
Advanced Trie Applications

Topic 22: Union Find (Disjoint Set)

Basic Union Find
Advanced Union Find

PHASE 5: ADVANCED ALGORITHMS

Topic 23: Advanced Graph Algorithms

Shortest Path Algorithms
Dijkstra's Algorithm:
Bellman-Ford & Floyd-Warshall:
Minimum Spanning Tree
Strongly Connected Components
Advanced Graph Problems

Topic 24: Advanced Binary Search

Search in Rotated Arrays
Binary Search on Answer

Topic 25: Segment Tree & Binary Indexed Tree

Segment Tree
Binary Indexed Tree (Fenwick Tree)

Topic 26: Advanced Bit Manipulation

XOR Problems
Bitmasking & State Compression
Advanced Bit Operations

Topic 27: Advanced Math & Number Theory

Prime Numbers & Factorization
GCD & LCM
Combinatorics & Probability
Geometry

WEEKLY MIXED PRACTICE SETS

Week 1 - Foundation Mix

Week 2 - Intermediate Mix

Week 3 - Advanced Mix


COMPANY-SPECIFIC PREPARATION

Google Top 50

Amazon Top 50

Meta (Facebook) Top 50

Microsoft Top 50


PATTERN REFERENCE GUIDE

Common Patterns to Master

1. Sliding Window Pattern

When to use: Problems involving subarrays/substrings with specific conditions

  • Fixed Window: Window size k is given
  • Variable Window: Find optimal window size
  • Two Pointers: Start and end pointers

Key Problems:

  • Maximum Sum Subarray of Size K
  • Longest Substring Without Repeating Characters
  • Minimum Window Substring
  • Permutation in String

Common Indicators:

  • "Maximum/minimum subarray/substring"
  • "Window of size k"
  • "Longest/shortest substring with condition"

2. Two Pointers Pattern

When to use: Sorted arrays, palindromes, or when you need to compare elements

  • Same Direction: Fast and slow pointers
  • Opposite Direction: Start and end converging
  • Multiple Arrays: Merge operations

Key Problems:

  • Two Sum (sorted array)
  • 3Sum
  • Container With Most Water
  • Valid Palindrome
  • Merge Sorted Array

Common Indicators:

  • "Pair with given sum"
  • "Triplet/quadruplet"
  • "Compare elements from both ends"
  • "Sorted array"

3. Fast & Slow Pointers (Floyd's Algorithm)

When to use: Cycle detection, finding middle element

  • Detect cycle in linked list
  • Find start of cycle
  • Find middle of linked list
  • Happy Number problem

Key Problems:

  • Linked List Cycle
  • Find Duplicate Number
  • Middle of Linked List
  • Palindrome Linked List

Common Indicators:

  • "Detect cycle"
  • "Find middle"
  • "Find duplicate in range [1,n]"

4. Merge Intervals Pattern

When to use: Overlapping intervals problems

Key Problems:

  • Merge Intervals
  • Insert Interval
  • Meeting Rooms I & II
  • Employee Free Time

Common Indicators:

  • "Overlapping intervals"
  • "Merge ranges"
  • "Free time"
  • "Conflict detection"

5. Cyclic Sort Pattern

When to use: Numbers in range [1, n], finding missing/duplicate

Key Problems:

  • Missing Number
  • Find All Duplicates
  • Find Duplicate Number
  • First Missing Positive

Common Indicators:

  • "Numbers from 1 to n"
  • "Find missing/duplicate"
  • "Constant space required"
  • "Array contains numbers in given range"

6. In-place Linked List Reversal

When to use: Reverse linked list problems

Key Problems:

  • Reverse Linked List
  • Reverse Linked List II
  • Reverse Nodes in k-Group
  • Rotate List

Common Indicators:

  • "Reverse linked list"
  • "Reverse in groups"
  • "Rotate list"

7. Tree BFS Pattern

When to use: Level-order traversal, shortest path in tree

Key Problems:

  • Binary Tree Level Order Traversal
  • Zigzag Level Order
  • Binary Tree Right Side View
  • Minimum Depth of Binary Tree
  • Connect Level Order Siblings

Common Indicators:

  • "Level by level"
  • "Level order"
  • "Shortest path in tree"
  • "Minimum depth"

8. Tree DFS Pattern

When to use: Path problems, subtree problems

Key Problems:

  • Path Sum (I, II, III)
  • Diameter of Binary Tree
  • Binary Tree Maximum Path Sum
  • Lowest Common Ancestor

Common Indicators:

  • "All paths"
  • "Path sum"
  • "Subtree"
  • "Ancestor problems"

9. Two Heaps Pattern

When to use: Finding median, scheduling problems

Key Problems:

  • Find Median from Data Stream
  • Sliding Window Median
  • IPO
  • Meeting Rooms III

Common Indicators:

  • "Median in stream"
  • "Schedule tasks"
  • "Balance between two halves"

10. Subsets Pattern (Backtracking)

When to use: Generate all combinations/permutations

Key Problems:

  • Subsets
  • Permutations
  • Combination Sum
  • Letter Combinations
  • Generate Parentheses

Common Indicators:

  • "All combinations"
  • "All permutations"
  • "All possible ways"
  • "Generate all"

11. Modified Binary Search

When to use: Sorted array with twist, find boundary

Key Problems:

  • Search in Rotated Sorted Array
  • Find Minimum in Rotated Sorted Array
  • Search a 2D Matrix
  • Find Peak Element
  • First Bad Version

Common Indicators:

  • "Sorted array"
  • "Find in O(log n)"
  • "Nearly sorted"
  • "Find peak/valley"

12. Top K Elements Pattern

When to use: Find k largest/smallest elements

Key Problems:

  • Kth Largest Element
  • Top K Frequent Elements
  • K Closest Points to Origin
  • Sort Characters By Frequency

Common Indicators:

  • "K largest/smallest"
  • "Top K"
  • "K most frequent"
  • "K closest"

13. K-way Merge Pattern

When to use: Merge k sorted arrays/lists

Key Problems:

  • Merge k Sorted Lists
  • Kth Smallest in Sorted Matrix
  • Smallest Range Covering Elements from K Lists
  • Find K Pairs with Smallest Sums

Common Indicators:

  • "Merge k sorted"
  • "K lists/arrays"
  • "Smallest range in k lists"

14. 0/1 Knapsack Pattern

When to use: Optimization with constraints

Key Problems:

  • Partition Equal Subset Sum
  • Target Sum
  • Coin Change 2
  • Last Stone Weight II

Common Indicators:

  • "Maximum value with weight limit"
  • "Subset with given sum"
  • "Ways to make change"
  • "Partition array"

15. Unbounded Knapsack Pattern

When to use: Unlimited use of elements

Key Problems:

  • Coin Change
  • Cutting Rod
  • Maximum Ribbon Cut
  • Minimum Cost for Tickets

Common Indicators:

  • "Unlimited use"
  • "Minimum coins"
  • "Cut into pieces"
  • "Multiple use allowed"

16. Fibonacci Pattern (DP)

When to use: Problems with recurrence relation

Key Problems:

  • Climbing Stairs
  • House Robber
  • Fibonacci Number
  • Jump Game

Common Indicators:

  • "Number of ways"
  • "Reach the end"
  • "Maximum profit without adjacent"

17. Palindromic Subsequence Pattern

When to use: Palindrome-related DP problems

Key Problems:

  • Longest Palindromic Substring
  • Longest Palindromic Subsequence
  • Count Palindromic Substrings
  • Minimum Deletions to Make Palindrome

Common Indicators:

  • "Palindrome"
  • "Longest palindromic"
  • "Minimum deletions for palindrome"

18. Longest Common Substring Pattern

When to use: Finding common patterns in strings

Key Problems:

  • Longest Common Subsequence
  • Edit Distance
  • Minimum Deletions & Insertions
  • Longest Increasing Subsequence

Common Indicators:

  • "Longest common"
  • "Edit distance"
  • "Convert string A to B"
  • "Minimum operations"

19. Topological Sort Pattern

When to use: Dependencies, prerequisites, ordering

Key Problems:

  • Course Schedule (I & II)
  • Alien Dictionary
  • Sequence Reconstruction
  • Minimum Height Trees

Common Indicators:

  • "Prerequisites"
  • "Dependencies"
  • "Ordering"
  • "Build order"
  • "Valid sequence"

20. Union Find Pattern

When to use: Connected components, detect cycles

Key Problems:

  • Number of Islands II
  • Redundant Connection
  • Accounts Merge
  • Satisfiability of Equality Equations

Common Indicators:

  • "Connected components"
  • "Groups/Sets"
  • "Detect cycle in undirected graph"
  • "Dynamic connectivity"

21. Monotonic Stack Pattern

When to use: Next greater/smaller element

Key Problems:

  • Next Greater Element
  • Daily Temperatures
  • Largest Rectangle in Histogram
  • Trapping Rain Water

Common Indicators:

  • "Next greater/smaller"
  • "Previous greater/smaller"
  • "Largest rectangle"
  • "Stock span"

22. Bit Manipulation Pattern

When to use: Optimize space, XOR properties

Key Problems:

  • Single Number
  • Number of 1 Bits
  • Counting Bits
  • XOR Queries

Common Indicators:

  • "Without extra space"
  • "Appears once/twice"
  • "Power of 2"
  • "XOR operations"

23. Trie Pattern

When to use: Prefix matching, word search

Key Problems:

  • Implement Trie
  • Word Search II
  • Design Add and Search Words
  • Replace Words

Common Indicators:

  • "Prefix"
  • "Word search"
  • "Auto-complete"
  • "Dictionary"

24. Graph Bipartite Pattern

When to use: Two-coloring problems

Key Problems:

  • Is Graph Bipartite?
  • Possible Bipartition
  • Color the Graph

Common Indicators:

  • "Two groups"
  • "No adjacent same"
  • "Bipartite"
  • "Two colors"

25. Minimum Spanning Tree Pattern

When to use: Connect all points with minimum cost

Key Problems:

  • Min Cost to Connect All Points
  • Connecting Cities With Minimum Cost
  • Optimize Water Distribution

Common Indicators:

  • "Connect all points"
  • "Minimum cost network"
  • "Minimum total weight"

Pattern Selection Flowchart

Start Here:

  1. Is it an Array/String problem?
  • Sorted? → Two Pointers / Binary Search
  • Subarray/Substring? → Sliding Window
  • Intervals? → Merge Intervals
  • Range [1,n]? → Cyclic Sort
  1. Is it a Linked List problem?
  • Reverse? → In-place Reversal
  • Cycle? → Fast & Slow Pointers
  • Merge? → Two Pointers
  1. Is it a Tree/Graph problem?
  • Level-wise? → BFS
  • Path/Subtree? → DFS
  • Shortest Path? → BFS/Dijkstra
  • Dependencies? → Topological Sort
  • Groups? → Union Find
  1. Is it an Optimization problem?
  • Choices at each step? → Dynamic Programming
  • Generate all solutions? → Backtracking
  • Local optimum → global? → Greedy
  • K elements? → Heap
  1. Is it a Search problem?
  • Sorted? → Binary Search
  • Prefix? → Trie
  • Next element? → Monotonic Stack

Time Complexity Cheat Sheet

Pattern Time Complexity Space Complexity
Sliding Window O(n) O(1) or O(k)
Two Pointers O(n) or O(nlogn) O(1)
Fast & Slow O(n) O(1)
Merge Intervals O(nlogn) O(n)
Cyclic Sort O(n) O(1)
Tree BFS O(n) O(n)
Tree DFS O(n) O(h)
Backtracking O(2^n) or O(n!) O(n)
Binary Search O(logn) O(1)
Heap Operations O(nlogk) O(k)
Dynamic Programming O(n²) or O(nm) O(n) or O(nm)
Topological Sort O(V+E) O(V+E)
Union Find O(α(n)) ≈ O(1) O(n)
Trie O(m) per operation O(ALPHABET_SIZE * m * n)

Quick Pattern Recognition Guide

If you see... Think...
"Maximum/minimum subarray" Sliding Window / Kadane's
"Sorted array" Binary Search / Two Pointers
"Top/kth element" Heap
"Generate all" Backtracking
"Optimize" Dynamic Programming
"Tree level" BFS
"Tree path" DFS
"Graph shortest path" BFS / Dijkstra
"Dependencies" Topological Sort
"Groups/Components" Union Find / DFS
"Parentheses/Brackets" Stack
"Next greater" Monotonic Stack
"Palindrome" Two Pointers / DP
"Overlapping intervals" Sort + Merge
"In-place" Cyclic Sort / Two Pointers
"Stream of data" Heap / Design
"Prefix" Trie
"Range query" Segment Tree / BIT

TIPS FOR MASTERY

Problem-Solving Strategy

  1. Understand the problem completely
  • Read the problem 2-3 times
  • Look at examples
  • Ask clarifying questions
  1. Identify the pattern
  • What category does this fall into?
  • Have you seen similar problems?
  • What data structure is most suitable?
  1. Start with brute force
  • Get a working solution first
  • Then optimize
  1. Optimize step by step
  • Time complexity
  • Space complexity
  • Code readability
  1. Handle edge cases
  • Empty input
  • Single element
  • Negative numbers
  • Overflow
  1. Test your solution
  • Walk through examples
  • Test edge cases
  • Verify complexity

Time Management

  • Easy Problems: 15-20 minutes
  • Medium Problems: 25-35 minutes
  • Hard Problems: 40-50 minutes
  • If stuck after allocated time, look at hints/discussion

Study Schedule

  • Daily: 2-3 problems (1 easy, 1-2 medium)
  • Weekly: 15-20 problems + 1-2 hard problems
  • Review: Revisit problems after 2-3 weeks
  • Mock Interviews: Weekly timed sessions

Common Mistakes to Avoid

  1. Jumping to code without understanding
  2. Not considering edge cases
  3. Ignoring time/space complexity
  4. Not testing with examples
  5. Over-complicating simple problems
  6. Under-estimating hard problems

Interview Tips

  1. Think out loud - Explain your thought process
  2. Ask questions - Clarify requirements
  3. Start simple - Begin with brute force
  4. Optimize - Discuss trade-offs
  5. Test - Walk through your solution
  6. Be receptive - Accept hints gracefully

RESOURCES

Books

  • Cracking the Coding Interview
  • Elements of Programming Interviews
  • Algorithm Design Manual

Online Platforms

  • LeetCode Discussion Forums
  • YouTube Channels (NeetCode, Back to Back SWE)
  • System Design Primer

Practice Platforms

  • LeetCode
  • HackerRank
  • CodeSignal
  • Pramp (Mock Interviews)

About

Comprehensive LeetCode study guide featuring 1500+ problems systematically organized across 71 topics. Includes foundation concepts, common patterns, edge cases, company-specific prep, and progress tracking.

Topics

Resources

License

Stars

Watchers

Forks