Product-Based & MAANG DSA Question Bank
(Medium + Hard) — Total Patterns: 147
Tags: Amazon, Google, Microsoft, Meta, Netflix, Apple
Arrays & Hashing
Medium
• Two Sum (indices) using hash map
• 3Sum (unique triplets)
• 4Sum (unique quadruplets)
• Subarray Sum Equals K (prefix sum + hashmap)
• Longest Subarray with 0 sum
• Longest Consecutive Sequence (hash set)
• Product of Array Except Self
• Maximum Product Subarray
• Sliding Window Maximum (deque/heap)
• Majority Element (Boyer-Moore)
• Rotate Array by k (cyclic replacement)
• Stock Buy & Sell (single transaction)
• Stock Buy & Sell (multiple transactions)
• Find Missing and Repeating numbers
Hard
• Median of Two Sorted Arrays (binary search partition)
• Trapping Rain Water (two pointers + stack)
• Container With Most Water
• 3Sum Closest
• Kth Largest Element in Array (heap/quickselect)
• Largest Rectangle in Histogram
• Maximum Sum Circular Subarray
• Minimum Window to be Sorted (subarray)
• Count Inversions in an Array
• Maximum Gap (bucket sort)
Strings
Medium
• Longest Substring Without Repeating Characters
• Minimum Window Substring
• Group Anagrams
• Valid Anagram
• Word Break I
• String Compression
• Remove Adjacent Duplicates
• Longest Common Prefix
• Roman to Integer / Integer to Roman
• Count and Say sequence
Hard
• Longest Palindromic Substring
• Longest Palindromic Subsequence
• Edit Distance (DP)
• Regular Expression Matching (DP)
• Wildcard Matching (DP)
• Word Break II (all sentences)
• Z Algorithm / KMP for pattern searching
• Longest Repeating Character Replacement
• Smallest Window Containing All Characters of Another String
• Encode and Decode Strings (design)
Linked List
Medium
• Reverse a Linked List
• Merge Two Sorted Lists
• Add Two Numbers (linked lists as digits)
• Detect & Remove Cycle
• Remove N-th Node from End
• Palindrome Linked List
• Odd-Even Linked List Reordering
• Intersection of Two Linked Lists
• Delete Node without Head Pointer
Hard
• Reverse Nodes in k-Group
• Copy List with Random Pointer
• LRU Cache (design)
• Flatten a Multilevel Linked List
• Reorder List (L0→Ln→L1→Ln-1…)
• Rotate List by k
• Sort Linked List (merge sort)
• Split Linked List into k Parts
• Swap Nodes in Pairs
Stack & Queue
Medium
• Min Stack (O(1) getMin)
• Next Greater Element I/II
• Evaluate Reverse Polish Notation
• Simplify Unix Path
• Balanced Parentheses
• Implement Queue using Stacks
• Sliding Window Maximum
• Stock Span Problem
• Daily Temperatures (monotonic stack)
Hard
• Largest Rectangle in Histogram
• Maximal Rectangle (2D)
• LRU/LFU Cache (design)
• Expression Evaluation with Precedence
• Remove k Digits to form Smallest Number
• Decode String with Nested Counts
Trees & BST
Medium
• Level Order Traversal
• Zigzag Traversal
• Diameter of Binary Tree
• Lowest Common Ancestor (BT & BST)
• Validate BST
• Kth Smallest in BST
• Construct Tree from Preorder & Inorder
• Boundary Traversal
• Top/Bottom/Vertical Order Traversals
Hard
• Serialize & Deserialize Binary Tree
• Binary Tree Maximum Path Sum
• Recover BST (two swapped nodes)
• Flatten Binary Tree to Linked List
• All Nodes at Distance K from Target
• Burning Tree / Time to Infect
• Construct from Inorder & Postorder
• Count Nodes in Complete Binary Tree
Graphs
Medium
• Number of Islands (DFS/BFS/Union-Find)
• Clone Graph
• Course Schedule I/II
• Topological Sort (DFS/Kahn)
• Connected Components Count
• Detect Cycle in Undirected Graph
• Detect Cycle in Directed Graph
• Flood Fill
• Shortest Path in Unweighted Graph (BFS)
Hard
• Dijkstra Shortest Path
• Bellman-Ford (negative cycles)
• Floyd-Warshall
• Minimum Spanning Tree (Kruskal/Prim)
• Kosaraju/Tarjan SCC
• Word Ladder (BFS shortest transformation)
• Minimum Time to Rot Oranges
• Graph Coloring (M-coloring backtracking)
Dynamic Programming
Medium
• Climbing Stairs / Min Cost Climbing Stairs
• House Robber I & II
• Coin Change (min coins)
• Coin Change (total combinations)
• Longest Increasing Subsequence
• Subset Sum Problem
• Partition Equal Subset Sum
• 0/1 Knapsack
• Unbounded Knapsack
• Unique Paths with Obstacles
Hard
• Longest Common Subsequence / Substring
• Palindrome Partitioning II (min cuts)
• Matrix Chain Multiplication
• Boolean Parenthesization
• Egg Dropping Puzzle
• Burst Balloons
• Regular Expression Matching (DP)
• Wildcard Matching (DP)
• Maximum Product Subarray (DP variant)
Advanced Topics
Medium
• Union-Find (Disjoint Set Union)
• Kth Largest in Stream (min-heap)
• Top K Frequent Elements
• Design Twitter Feed (heap + map)
• Implement Trie (Prefix Tree)
• Autocomplete System (Trie + Heap)
• Segment Tree Basics (Range Sum)
• Fenwick Tree Basics
Hard
• Design TinyURL (hash + collision handling)
• LFU Cache (design)
• Design In-Memory Key-Value Store
• Design Leaderboard (heap + map)
• Rearrange String k Distance Apart
• Minimum Refueling Stops
• Median of Data Stream (two heaps)
• Range Minimum Query using Segment Tree
• Maximum Flow (Ford-Fulkerson/Edmonds-Karp)
—
Practice Tips
• Target 2 Medium + 2 Hard per day, review solutions thoroughly.
• Explain your thought process and optimize step-by-step.
• Common patterns: sliding window, prefix-sum, binary search on answer, heaps, tries, DP.
• For MAANG, prepare for multiple follow-ups per problem.
• Use the Excel tracker to mark ■ → ■ after solving.