https://gist.github.com/carefree-ladka/965124eb973eb448ad117016013ec0ec
- LeetCode Patterns - Curated problem list by pattern
- NeetCode Roadmap - 150 essential problems
- Tech Interview Handbook - Complete interview prep
- Visualgo - Algorithm visualizations
- Big-O Cheat Sheet - Time/space complexity reference
- CP-Algorithms - Detailed algorithm explanations
- NeetCode YouTube - Problem walkthroughs
- Abdul Bari Algorithms - Algorithm fundamentals
- William Fiset Data Structures - Advanced DS
- LeetCode - Primary platform
- Codeforces - Competitive programming
- AtCoder - Quality problems
- HackerRank - Interview prep
- Pramp - Free mock interviews
- Arrays & Strings
- Hashing (Map/Set)
- Intervals & Line Sweep
- Important Algorithms
- Searching & Sorting
- Linked Lists
- Stacks & Queues
- Recursion & Backtracking
- Trees
- Graphs
- Heaps/Priority Queue
- Greedy Algorithms
- Dynamic Programming
- Tries
- Bit Manipulation
- Math & Number Theory
- Advanced Topics
- System Design Foundations
- Google Interview Tips
- Array traversal (forward, backward, nested)
- Prefix sum and suffix sum
- Difference array
- In-place modifications (constant space)
- Custom sorting with comparators
- Frequency arrays and counting
- String parsing and manipulation
- Character encoding (ASCII, Unicode)
- String builders for efficiency
- Sliding Window (fixed and variable size)
- Two Pointers (same direction, opposite direction)
- Prefix Sum + HashMap (subarray problems)
- Kadane's Algorithm (maximum subarray)
- Cyclic Sort (missing/duplicate numbers)
- Dutch National Flag (three-way partitioning)
- Expand Around Center (palindromes)
- Fast & Slow Pointers (cycle detection in arrays)
- Matrix traversal (spiral, diagonal, layer-by-layer)
- Rotate array
- Product of array except self
- Trapping rain water
- Container with most water
- Longest substring without repeating characters
- Minimum window substring
- String compression
- Zigzag conversion
Easy:
Medium:
- 3Sum
- Longest Substring Without Repeating Characters
- Longest Repeating Character Replacement
- Container With Most Water
- Product of Array Except Self
- Maximum Subarray (Kadane's)
- Subarray Sum Equals K
Hard:
- HashMap vs Object vs Map (language-specific)
- Hash collisions and resolution strategies
- Frequency counting
- Grouping and bucketing
- Set operations (union, intersection, difference)
- LinkedHashMap for insertion order
- Custom hash functions
- Two Sum / k-Sum variants
- Anagram grouping
- Subarray sum equals K
- Longest substring with constraints
- Seen-before logic (first unique, duplicates)
- Complement pattern (pair finding)
- Rolling hash (Rabin-Karp for pattern matching)
- Group anagrams
- Top K frequent elements
- Longest consecutive sequence
- Subarray sum divisible by K
- Count distinct elements in window
Easy:
Medium:
- Group Anagrams
- Top K Frequent Elements
- Subarray Sum Equals K
- Longest Consecutive Sequence
- 4Sum II
- Encode and Decode TinyURL
Hard:
- Interval representation
[start, end] - Overlapping intervals
- Merging intervals
- Sorting by start/end times
- Event-based processing
- Sweep line technique
- Sort by start time
- Iterate and merge overlapping intervals
- Track current interval
- Two-pointer approach
- Check overlap conditions
- Generate intersection intervals
- Sort by end time (greedy)
- Select non-overlapping intervals
- Maximum activities selection
- Convert intervals to events (start/end)
- Sort events by time
- Process events in order
- Track active intervals count
- Use for overlap detection
- Merge Intervals
- Insert Interval
- Interval List Intersections
- Non-overlapping Intervals (minimum removals)
- Meeting Rooms (I, II)
- Minimum Number of Arrows (burst balloons)
- My Calendar (I, II, III)
- Car Pooling
- Corporate Flight Bookings
- The Skyline Problem (advanced)
- Rectangle Area (overlap/union)
- Perfect Rectangle
- Employee Free Time
- Remove Covered Intervals
- Video Stitching
- Finding maximum overlapping intervals
- Range queries with updates
- Coordinate compression
- 2D geometry problems
- Event scheduling conflicts
Easy:
- Meeting Rooms (Premium)
- Summary Ranges
Medium:
- Merge Intervals
- Insert Interval
- Non-overlapping Intervals
- Meeting Rooms II (Premium)
- My Calendar I
- My Calendar II
- Interval List Intersections
- Minimum Number of Arrows to Burst Balloons
- Car Pooling
- Employee Free Time (Premium)
Hard:
Purpose: Maximum subarray sum
Concept:
- Track current sum and global max
- Reset current sum if it becomes negative
- O(n) time, O(1) space
Applications:
- Maximum subarray sum
- Maximum product subarray (variant)
- Maximum circular subarray
- Maximum sum rectangle in 2D array
- Best time to buy and sell stock
Implementation Pattern:
maxSum = -infinity
currentSum = 0
for each element:
currentSum = max(element, currentSum + element)
maxSum = max(maxSum, currentSum)
Purpose: Find element appearing > n/2 times
Concept:
- Maintain candidate and count
- Cancel out different elements
- O(n) time, O(1) space
Applications:
- Majority element (> n/2)
- Majority element II (> n/3) - needs 2 candidates
- Finding dominant elements
Implementation Pattern:
candidate = null
count = 0
for each element:
if count == 0:
candidate = element
count += (element == candidate) ? 1 : -1
// Verify candidate appears > n/2 times
Purpose: Find kth smallest/largest element
Concept:
- Partition array like quicksort
- Only recurse on relevant partition
- Average O(n), worst O(nΒ²)
Applications:
- Kth largest/smallest element
- Top K elements (alternative to heap)
- Median finding
- Quick select with random pivot (better average case)
Implementation Pattern:
function quickSelect(arr, k):
pivot = partition(arr)
if pivot == k:
return arr[pivot]
elif pivot > k:
recurse on left partition
else:
recurse on right partition
Purpose: Optimize array/string problems from O(nΒ²) to O(n)
Variants:
-
Opposite Direction (start and end)
- Two sum in sorted array
- Container with most water
- Valid palindrome
- Trapping rain water
-
Same Direction (slow and fast)
- Remove duplicates
- Move zeros
- Partition problems
-
Sliding Window (extension of two pointers)
- Fixed size windows
- Variable size windows
Purpose: Detect cycles in linked list/array
Concept:
- Slow pointer moves 1 step
- Fast pointer moves 2 steps
- If cycle exists, they meet
- O(n) time, O(1) space
Applications:
- Linked list cycle detection
- Find cycle start point
- Find duplicate number (treating array as linked list)
- Happy number problem
Finding Cycle Start:
1. Detect cycle (slow meets fast)
2. Reset slow to start
3. Move both one step at a time
4. Meeting point is cycle start
Purpose: Optimize substring/subarray problems
Types:
-
Fixed Size Window
- Maximum sum of k consecutive elements
- Average of subarrays of size k
-
Variable Size Window
- Longest substring without repeating characters
- Minimum window substring
- Longest substring with at most k distinct
Pattern:
left = 0
for right in range(n):
add arr[right] to window
while window invalid:
remove arr[left] from window
left++
update result
Purpose: Partition array into three sections
Concept:
- Three pointers: low, mid, high
- Elements < pivot go left
- Elements == pivot stay middle
- Elements > pivot go right
- O(n) time, O(1) space
Applications:
- Sort colors (0s, 1s, 2s)
- Three-way quicksort
- Partition array by pivot
Purpose: Efficient pattern matching
Concept:
- Preprocess pattern to build LPS array
- Avoid redundant comparisons
- O(m + n) time vs O(m*n) naive
Applications:
- String pattern matching
- Repeated substring pattern
- Shortest palindrome
Purpose: Pattern matching using rolling hash
Concept:
- Hash the pattern
- Roll hash through text
- Compare only on hash match
- Average O(m + n), worst O(m*n)
Applications:
- Multiple pattern matching
- Plagiarism detection
- Longest duplicate substring
Purpose: Track connected components efficiently
Operations:
find(x)- find root with path compressionunion(x, y)- merge sets with union by rank
Time Complexity:
- Nearly O(1) per operation with optimizations
Applications:
- Number of connected components
- Detect cycles in undirected graph
- Kruskal's MST
- Accounts merge
- Redundant connection
Purpose: Maintain elements in monotonic order
Monotonic Stack:
- Next greater/smaller element
- Largest rectangle in histogram
- Trapping rain water
Monotonic Queue (Deque):
- Sliding window maximum/minimum
- Jump game variations
- Maximum Subarray
- Maximum Product Subarray
- Maximum Sum Circular Subarray
- Best Time to Buy and Sell Stock
- Number of Connected Components (Premium)
- Graph Valid Tree (Premium)
- Accounts Merge
- Redundant Connection
- Most Stones Removed
- Binary search (classic, lower bound, upper bound) | https://gist.github.com/carefree-ladka/fee1eda3f6336cd18d7d34c78e6acae0#1-classic-binary-search-exact-match
- Binary search on answer space
- Exponential search
- Ternary search
- Search in rotated sorted array
- Search in 2D matrix
- Peak element finding
- Square root calculation
- First and last position
- Quick Select (for kth element)
- Quick sort (and its variants)
- Merge sort (and external sorting)
- Counting sort
- Radix sort
- Bucket sort
- Heap sort
- Custom comparator logic
- Stability in sorting
- External sorting concepts
- Binary Search on monotonic condition
- Divide & Conquer
- Partitioning strategies
- Invariant maintenance
Binary Search:
- Binary Search
- Search in Rotated Sorted Array
- Find Minimum in Rotated Sorted Array
- Search a 2D Matrix
- Koko Eating Bananas
- Capacity To Ship Packages
- Median of Two Sorted Arrays
Sorting:
- Singly linked list
- Doubly linked list
- Circular linked list
- Fast & slow pointers (Floyd's algorithm)
- Sentinel/dummy nodes
- In-place modifications
- Reverse list (full/partial/k-groups)
- Detect and remove cycle (Floyd's)
- Find middle node
- Merge sorted lists
- K-group reversal
- Copy list with random pointer
- Intersection of lists
- Palindrome check
- Reorder list
- Flatten multilevel list
- Add two numbers
- Remove Nth node from end
- Rotate list
- Sort list
- Partition list
Easy:
Medium:
- Reorder List
- Remove Nth Node From End
- LRU Cache
- Add Two Numbers
- Copy List with Random Pointer
- Reverse Nodes in k-Group
Hard:
- Monotonic stack (increasing/decreasing)
- Next greater/smaller element
- Valid parentheses and variants
- Expression evaluation (infix, postfix, prefix)
- Histogram problems (largest rectangle)
- Stock span problem
- Decode string
- Simplify path
- Min/Max stack
- Sliding window maximum (deque)
- BFS (level-order traversal)
- Circular queue
- Design queue using stacks
- Moving average from data stream
- Recent counter/time-based problems
Stack:
- Valid Parentheses
- Min Stack
- Evaluate Reverse Polish Notation
- Daily Temperatures
- Car Fleet
- Next Greater Element I
- Largest Rectangle in Histogram
Queue/Deque:
- Call stack and memory
- Base case design
- ChoiceβExploreβUnchoose paradigm
- Pruning techniques
- State management
- Tail recursion optimization
- Subsets (with/without duplicates)
- Permutations (with/without duplicates)
- Combinations
- Combination sum (variants)
- Palindrome partitioning
- Sudoku solver
- N-Queens
- Word search (grid backtracking)
- Generate parentheses
- Letter combinations
- Expression add operators
- Restore IP addresses
Medium:
- Subsets
- Subsets II
- Permutations
- Permutations II
- Combination Sum
- Combination Sum II
- Combinations
- Generate Parentheses
- Word Search
- Palindrome Partitioning
- Letter Combinations of a Phone Number
Hard:
- DFS traversals (preorder, inorder, postorder)
- BFS/Level order traversal
- Height and depth
- Diameter calculation
- Path sum problems
- Balanced tree check
- Symmetric tree
- Serialize/Deserialize
- Iterative traversals using stack
- Insert/Delete/Search operations
- Validate BST
- Lowest Common Ancestor (LCA)
- Kth smallest/largest element
- Range sum query
- Inorder successor/predecessor
- Convert sorted array to BST
- BST iterator
- Tree paths (root to leaf, any path)
- Tree pruning
- Tree flattening
- Boundary traversal
- Vertical order traversal
- Diagonal traversal
- View problems (left, right, top, bottom)
- Morris traversal (constant space)
- Threaded binary trees
- Construct tree from traversals
- Maximum path sum
- Traversal variations
- Level order with null markers
- Encode/decode
Easy:
Medium:
- Binary Tree Level Order Traversal
- Binary Tree Right Side View
- Validate Binary Search Tree
- Kth Smallest Element in a BST
- Construct Binary Tree from Preorder and Inorder
- Lowest Common Ancestor of a Binary Tree
- Binary Tree Zigzag Level Order
- Diameter of Binary Tree
- Count Good Nodes in Binary Tree
Hard:
- Adjacency list vs matrix
- Directed vs undirected
- Weighted vs unweighted
- Sparse vs dense graphs
- Edge list representation
- BFS (shortest path in unweighted)
- DFS (recursive + iterative)
- Multi-source BFS
- Bidirectional BFS
- Connected components
- Cycle detection (directed using colors, undirected using parent)
- Topological sort (Kahn's algorithm + DFS)
- Shortest path (BFS, Dijkstra, Bellman-Ford)
- Union Find (DSU) (path compression, union by rank)
- Flood fill
- Bipartite graph check
- Strongly connected components (Kosaraju's, Tarjan's)
- Minimum spanning tree (Kruskal's, Prim's)
- Bridges and articulation points
- Eulerian path/circuit
- Course schedule variations
- Word ladder
- Alien dictionary
- Network delay time
- Cheapest flights within K stops
- Critical connections (bridges)
- Reconstruct itinerary (Eulerian path)
- Evaluate division
- Accounts merge (Union-Find)
- Clone graph
- Smallest string with swaps (Union-Find)
- Optimize water distribution
Medium:
- Number of Islands
- Clone Graph
- Pacific Atlantic Water Flow
- Course Schedule
- Course Schedule II
- Graph Valid Tree (Premium)
- Number of Connected Components (Premium)
- Rotting Oranges
- Walls and Gates (Premium)
- Redundant Connection
- Word Ladder
- Surrounded Regions
Hard:
- Word Ladder II
- Alien Dictionary (Premium)
- Minimum Cost to Connect All Points
- Network Delay Time
- Swim in Rising Water
- Critical Connections in a Network
- Min heap and max heap
- Heapify operation
- Custom comparators
- Heap as array representation
- Building heap from array (O(n))
- Top K elements (K largest/smallest)
- Kth largest/smallest
- Merge K sorted lists/arrays
- Sliding window median
- Median from data stream (two heaps)
- Task scheduling problems
- Meeting rooms variations
- K closest points
- Reorganize string
- Find K pairs with smallest sum
- IPO problem (maximize capital)
Easy:
Medium:
- Kth Largest Element in an Array
- K Closest Points to Origin
- Top K Frequent Elements
- Top K Frequent Words
- Task Scheduler
- Reorganize String
Hard:
- Greedy choice property
- Optimal substructure
- Proof of correctness
- When greedy works vs when it doesn't
- Interval scheduling (activity selection)
- Merge intervals
- Minimum platforms/meeting rooms
- Jump game (I, II)
- Gas station
- Candy distribution
- Partition labels
- Remove K digits
- Bag of tokens
- Queue reconstruction
- Fractional knapsack
- Huffman encoding (conceptual)
Easy:
Medium:
- Jump Game
- Jump Game II
- Gas Station
- Hand of Straights
- Merge Intervals
- Non-overlapping Intervals
- Partition Labels
Hard:
- Overlapping subproblems
- Optimal substructure
- Memoization (top-down) vs Tabulation (bottom-up)
- State definition and transitions
- Space optimization techniques
- Identifying DP problems
- Fibonacci variations
- House robber
- Climbing stairs
- Decode ways
- Maximum product subarray
- Coin change (ways and minimum)
- Perfect squares
- Integer break
- Grid paths
- Unique paths
- Unique paths with obstacles
- Min path sum
- Dungeon game
- Cherry pickup
- Longest Common Subsequence (LCS)
- Longest Increasing Subsequence (LIS)
- Edit distance (Levenshtein)
- Longest palindromic subsequence
- Shortest common supersequence
- Distinct subsequences
- Minimum ASCII delete sum
- 0/1 knapsack
- Unbounded knapsack
- Subset sum
- Partition equal subset sum
- Target sum
- Last stone weight II
- Palindrome partitioning (I, II, III)
- Word break (I, II)
- Regex matching
- Wildcard matching
- Interleaving strings
- Scramble string
- Tree DP fundamentals
- Maximum path sum (any to any)
- House robber III
- Binary tree cameras
- Longest univalue path
- Burst balloons
- Minimum cost tree from leaf values
- Remove boxes
- Strange printer
- State compression techniques
- Traveling salesman problem (TSP)
- Partition to K equal sum subsets
- Minimum XOR sum of two arrays
- Maximum students taking exam
- Stone game variations
- Predict the winner
- Cat and mouse game
- Digit DP
- DP with optimization (monotonic queue, divide and conquer)
- Probability DP
- Expected value DP
1D DP:
- Climbing Stairs
- House Robber
- House Robber II
- Decode Ways
- Coin Change
- Maximum Product Subarray
- Word Break
2D DP:
- Unique Paths
- Longest Common Subsequence
- Longest Increasing Subsequence
- Edit Distance
- Distinct Subsequences
- Interleaving String
Knapsack:
Advanced:
- Regular Expression Matching
- Wildcard Matching
- Burst Balloons
- Palindrome Partitioning II
- Best Time to Buy and Sell Stock IV
- Insert, search, prefix search
- Trie node structure
- Trie vs HashMap tradeoffs
- Space optimization (compressed trie)
- Delete operations
- Word search (grid + trie)
- Auto complete/suggestions
- Replace words
- Longest word in dictionary
- XOR maximum problems (binary trie)
- Design search autocomplete system
- Map sum pairs
- Stream of characters
Medium:
- Implement Trie (Prefix Tree)
- Design Add and Search Words Data Structure
- Replace Words
- Longest Word in Dictionary
- Maximum XOR of Two Numbers
Hard:
- Bitwise operators (AND, OR, XOR, NOT)
- Left shift and right shift
- Two's complement
- Signed vs unsigned
- Bitwise tricks and optimizations
- Single number (variants I, II, III)
- Power of two
- Count set bits (Hamming weight)
- Subsets using bitmask
- XOR tricks (swap without temp, missing number)
- Gray code
- Reverse bits
- Number complement
- Maximum XOR (binary trie)
- Bitwise AND of numbers range
- Divide two integers (bit manipulation)
Easy:
Medium:
- GCD/LCM (Euclidean algorithm)
- Prime numbers
- Sieve of Eratosthenes
- Prime factorization
- Count primes
- Modular arithmetic
- Properties
- Modular inverse
- Fast exponentiation (binary exponentiation)
- Combinations & permutations
- Pascal's triangle
- Catalan numbers
- Probability basics
- Matrix operations
- Multiplication
- Rotation
- Spirals
- Number systems (binary, decimal, hex)
- Perfect squares/cubes
- Ugly numbers
- Happy numbers
- Build, query, update
- Range sum/min/max queries
- Lazy propagation
- Applications in range problems
- Build and query
- Range sum queries
- Point updates
- 2D Fenwick tree
- Interval problems
- Skyline problem
- Rectangle overlap/area
- Point, line, and segment operations
- Convex hull
- Closest pair of points
- Line intersection
- Quick select (randomized)
- Reservoir sampling
- Random pick with weight
- Shuffle array
- KMP (Knuth-Morris-Pratt pattern matching)
- Rabin-Karp (rolling hash)
- Z-algorithm
- Manacher's algorithm (longest palindrome in O(n))
- Suffix array
- LCP array (Longest Common Prefix)
- Aho-Corasick (multiple pattern matching)
- Boyer-Moore (pattern matching with bad character/good suffix rules)
- Sliding window problems
- Jump game variations
- Path compression
- Union by rank/size
- Applications beyond basic union-find
While not strictly DSA, Google interviews may touch on:
- Scalability concepts
- Caching strategies (LRU, LFU cache)
- Rate limiting (token bucket, leaky bucket)
- Consistent hashing
- Load balancing basics
- Database indexing (B-trees, hash indexes)
- Distributed systems concepts (CAP theorem basics)
- Design problems
- Design Twitter/Instagram feed
- Design URL shortener
- Design LRU cache
- Design hit counter
- Design rate limiter
-
Problem Decomposition
- Break complex problems into manageable parts
- Identify subproblems
- Explain your thought process
-
Clear State Definition (especially DP)
- Define what each state represents
- Explain transitions
- Justify correctness
-
Edge Cases
- Empty inputs
- Single elements
- Duplicates
- Null/undefined
- Integer overflow
- Negative numbers
-
Time-Space Tradeoffs
- Discuss multiple approaches
- Optimize when asked
- Know when to use extra space
-
Code Quality
- Readable variable names
- Modular functions
- Clean logic flow
- Consistent style
-
Communication
- Think aloud
- Ask clarifying questions
- Explain before coding
- Test your solution
- LeetCode patterns: Focus on medium/hard problems
- Mock interviews: Practice explaining solutions
- Time yourself: Aim for 30-35 minutes per problem
- Review solutions: Learn optimal approaches
- Weekly targets:
- 15-20 problems for active prep
- Focus on weak areas
- Revisit problems after a week
- Clarify requirements and constraints
- Discuss brute force first (shows problem understanding)
- Optimize before coding (saves time)
- Write clean code with good variable names
- Test with examples (normal, edge, large)
- Be open to hints and feedback
- Arrays & Strings
- Important Algorithms (Kadane's, Boyer-Moore, Quick Select, etc.)
- Intervals & Line Sweep
- Hashing
- Trees (especially BST)
- Graphs (BFS/DFS/shortest path)
- Dynamic Programming
- Binary Search
- Heaps/Priority Queue
- Stacks & Queues
- Linked Lists
- Recursion & Backtracking
- Greedy
- Tries
- Bit Manipulation
- Sorting algorithms
- Segment Tree/Fenwick Tree
- Advanced graph algorithms
- String algorithms
- Bitmask DP
Remember: Google values problem-solving ability and clear communication over memorization. Focus on understanding patterns and explaining your reasoning!