Data Structures & Algorithms
DSA Roadmap: The Complete Data Structures & Algorithms Learning Path
From fundamentals to advanced patterns. Work through each phase in order for the best results.
Hash Map / Set
Trade space for time using O(1) lookup to find pairs, duplicates, and frequencies.
| Problem | Difficulty | Companies | Frequency | Solution | Link | |
|---|---|---|---|---|---|---|
| Contains Duplicate
#Array
#Hash Table
#Sorting | Easy | AmazonGoogle +1 | High | Solution | ||
| Isomorphic Strings
#Hash Table
#String | Easy | LinkedInAmazon | Medium | Solution | ||
| Number of Good Pairs
#Array
#Hash Table
#Math | Easy | Amazon | Medium | Solution | ||
| Two Sum
#Array
#Hash Map | Easy | AmazonGoogle +3 | High | Solution | ||
| Valid Anagram
#String
#Hash Map
#Sorting | Easy | AmazonApple +1 | High | Solution | ||
| Word Pattern
#Hash Table
#String | Easy | LinkedInDropbox | Medium | Solution | ||
| 4Sum II
#Array
#Hash Table | Medium | AmazonGoogle | Medium | Solution | ||
| Group Anagrams
#String
#Hash Map
#Sorting | Medium | AmazonFacebook +2 | High | Solution | ||
| Longest Consecutive Sequence
#Array
#Hash Set | Medium | GoogleFacebook +1 | High | Solution | ||
| LRU Cache
#Hash Table
#Linked List
#Design | Medium | AmazonMicrosoft +5 | High | Solution | ||
| Subarray Sum Divisible by K
#Array
#Hash Table
#Prefix Sum | Medium | FacebookAmazon +1 | Medium | Solution | ||
| Top K Frequent Elements
#Array
#Hash Map
#Heap | Medium | FacebookAmazon +1 | High | Solution |
Two Pointers
Use two indices moving toward each other or in the same direction to solve linear problems.
| Problem | Difficulty | Companies | Frequency | Solution | Link | |
|---|---|---|---|---|---|---|
| Majority Element
#Array | Easy | AmazonGoogle +1 | High | Solution | ||
| Majority Element II
#Array | Easy | AmazonGoogle +1 | High | Solution | ||
| Move Zeroes
#Array
#Two Pointers | Easy | FacebookBloomberg | Medium | Solution | ||
| Remove Duplicates from Sorted Array
#Array
#Two Pointers | Easy | AppleMicrosoft | High | Solution | ||
| Squares of a Sorted Array
#Array
#Two Pointers
#Sorting | Easy | GoogleAmazon +1 | High | Solution | ||
| Valid Palindrome
#String
#Two Pointers | Easy | FacebookMicrosoft +1 | High | Solution | ||
| Valid Palindrome II
#String
#Greedy
#Two Pointers | Easy | FacebookAmazon +1 | High | Solution | ||
| 3Sum
#Array
#Two Pointers
#Sorting | Medium | FacebookAmazon +2 | High | Solution | ||
| 3Sum Closest
#Array | Medium | AmazonGoogle +1 | High | Solution | ||
| 4Sum
#Array
#Sorting
#Two Pointers | Medium | AmazonAdobe | Medium | Solution | ||
| Assign Cookies
#Array | Medium | AmazonGoogle +1 | High | Solution | ||
| Best Time to Buy and Sell the Stocks - 2
#Array | Medium | AmazonGoogle +1 | High | Solution | ||
| Boats to Save People
#Array
#Two Pointers
#Greedy | Medium | AmazonGoogle | Medium | Solution | ||
| Container With Most Water
#Array
#Two Pointers
#Greedy | Medium | AmazonFacebook +3 | High | Solution | ||
| Count Inversions
#Array | Medium | AmazonGoogle +1 | High | Solution | ||
| Count Numbers with Unique Digits
#Array | Medium | AmazonGoogle +1 | High | Solution | ||
| Count Primes
#Array | Medium | AmazonGoogle +1 | High | Solution | ||
| Distribute Candies
#Array | Medium | AmazonGoogle +1 | High | Solution | ||
| Encode and Decode Strings
Premium
#Array
#String
#Design | Medium | GoogleFacebook +2 | Medium | Solution | ||
| Excel Sheet Column Number
#Array | Medium | AmazonGoogle +1 | High | Solution | ||
| Excel Sheet Column Title
#Array | Medium | AmazonGoogle +1 | High | Solution | ||
| Find N Unique Integers Sum up to Zero
#Array | Medium | AmazonGoogle +1 | High | Solution | ||
| Find the Duplicate Number
#Array | Medium | AmazonGoogle +1 | High | Solution | ||
| First Missing Positive
#Array | Medium | AmazonGoogle +1 | High | Solution | ||
| Hamming Distance
#Array | Medium | AmazonGoogle +1 | High | Solution | ||
| Happy Number
#Array | Medium | AmazonGoogle +1 | High | Solution | ||
| Insert Delete GetRandom in O
#Array | Medium | AmazonGoogle +1 | High | Solution | ||
| Intersection of two Arrays
#Array | Medium | AmazonGoogle +1 | High | Solution | ||
| Max sum path in two arrays
#Array | Medium | AmazonGoogle +1 | High | Solution | ||
| Maximum Sum Rectangle
#Array | Medium | AmazonGoogle +1 | High | Solution | ||
| Merge Sort
#Array | Medium | AmazonGoogle +1 | High | Solution | ||
| Minimum Length of String After Deleting Similar Ends
#String
#Two Pointers | Medium | Google | Low | Solution | ||
| Minimum Number of Moves to Make Palindrome
#String | Medium | AmazonGoogle +1 | High | Solution | ||
| Minimum Platforms
#Array | Medium | AmazonGoogle +1 | High | Solution | ||
| Next Greater Element III
#Array | Medium | AmazonGoogle +1 | High | Solution | ||
| Pairs of Songs With Total Durations Divisible by 60
#Array | Medium | AmazonGoogle +1 | High | Solution | ||
| Pascals Triangle
#Array | Medium | AmazonGoogle +1 | High | Solution | ||
| Power of Three
#Array | Medium | AmazonGoogle +1 | High | Solution | ||
| Rectangle Overlap
#Array | Medium | AmazonGoogle +1 | High | Solution | ||
| Repeat and Missing Number Array
#Array | Medium | AmazonGoogle +1 | High | Solution | ||
| Reverse words in a given string
#String | Medium | AmazonGoogle +1 | High | Solution | ||
| Reverse Words in a String
#String | Medium | AmazonGoogle +1 | High | Solution | ||
| Rotate Array
#Array | Medium | AmazonGoogle +1 | High | Solution | ||
| Segregate Even and Odd numbers
#Array | Medium | AmazonGoogle +1 | High | Solution | ||
| Shuffle an Array
#Array | Medium | AmazonGoogle +1 | High | Solution | ||
| Sign of the Product of an Array
#Array | Medium | AmazonGoogle +1 | High | Solution | ||
| Sort Colors
#Array
#Sorting
#Two Pointers | Medium | FacebookMicrosoft +1 | High | Solution | ||
| Subarray with 0 sum exist
#Array | Medium | AmazonGoogle +1 | High | Solution | ||
| Transpose Matrix
#Array | Medium | AmazonGoogle +1 | High | Solution | ||
| Two Sum II - Input Array Is Sorted
#Array
#Two Pointers
#Binary Search | Medium | AmazonApple | High | Solution | ||
| Trapping Rain Water
#Array
#Two Pointers
#Stack | Hard | AmazonGoogle +2 | High | Solution |
Sliding Window
Efficiently process subarrays or substrings of a fixed or variable size.
| Problem | Difficulty | Companies | Frequency | Solution | Link | |
|---|---|---|---|---|---|---|
| Consecutive 1's not allowed
#String | Medium | AmazonGoogle +1 | High | Solution | ||
| Count Number of Nice Subarrays
#Array
#Hash Table
#Math | Medium | Amazon | Medium | Solution | ||
| Find All Anagrams in a String
#String
#Hash Map
#Sliding Window | Medium | FacebookUber | Medium | Solution | ||
| Find the Index of the First Occurrence in a String
#String | Medium | AmazonGoogle +1 | High | Solution | ||
| First Unique Character in a String
#String | Medium | AmazonGoogle +1 | High | Solution | ||
| Frequency of the Most Frequent Element
#Array
#Binary Search
#Greedy | Medium | AmazonGoogle | Medium | Solution | ||
| Fruit Into Baskets
#Array
#Sliding Window
#Hash Map | Medium | Google | Low | Solution | ||
| Integer to Roman
#String | Medium | AmazonGoogle +1 | High | Solution | ||
| Largest Alphabetic Character present in the String
#String | Medium | AmazonGoogle +1 | High | Solution | ||
| Length of Last Word
#String | Medium | AmazonGoogle +1 | High | Solution | ||
| Longest Common Prefix
#String | Medium | AmazonGoogle +1 | High | Solution | ||
| Longest Repeating Character Replacement
#String
#Sliding Window | Medium | GoogleAmazon | Medium | Solution | ||
| Longest Subarray of 1's After Deleting One Element
#Array
#Dynamic Programming
#Sliding Window | Medium | AmazonGoogle +1 | Medium | Solution | ||
| Longest Substring Without Repeating Characters
#String
#Hash Map
#Sliding Window | Medium | AmazonGoogle +2 | High | Solution | ||
| Max Consecutive Ones III
#Array
#Sliding Window
#Binary | Medium | GoogleAmazon | Medium | Solution | ||
| Maximum Number of Vowels in a Substring of Given Length
#String
#Sliding Window | Medium | GoogleBloomberg +1 | Medium | Solution | ||
| Minimum changes to make alternating binary string
#String | Medium | AmazonGoogle +1 | High | Solution | ||
| Minimum Operations to Reduce X to Zero
#Array
#Hash Table
#Binary Search | Medium | AmazonGoogle | Medium | Solution | ||
| Minimum Size Subarray Sum
#Array
#Sliding Window
#Binary Search | Medium | AmazonFacebook | Medium | Solution | ||
| Permutation in String
#String
#Hash Map
#Sliding Window | Medium | MicrosoftAmazon | Medium | Solution | ||
| Roman to Integer
#String | Medium | AmazonGoogle +1 | High | Solution | ||
| Run Length Encoding
#String | Medium | AmazonGoogle +1 | High | Solution | ||
| String to Integer
#String | Medium | AmazonGoogle +1 | High | Solution | ||
| Subarray Product Less Than K
#Array
#Sliding Window | Medium | Amazon | Low | Solution | ||
| Valid Tic Toe State
#String | Medium | AmazonGoogle +1 | High | Solution | ||
| Minimum Window Substring
#String
#Hash Map
#Sliding Window | Hard | FacebookAmazon +2 | High | Solution | ||
| Sliding Window Maximum
#Array
#Deque
#Sliding Window | Hard | AmazonGoogle +1 | Medium | Solution |
Stack
LIFO structure for matching brackets, evaluating expressions, and monotonic problems.
| Problem | Difficulty | Companies | Frequency | Solution | Link | |
|---|---|---|---|---|---|---|
| Minimum invalid parentheses to remove to make valid parentheses
#Stack | Easy | AmazonGoogle +1 | High | Solution | ||
| Valid Parentheses
#String
#Stack | Easy | GoogleAmazon +2 | High | Solution | ||
| Asteroid Collision
#Array
#Stack
#Simulation | Medium | AmazonGoogle +1 | Medium | Solution | ||
| Basic Calculator II
#Math
#String
#Stack | Medium | AmazonFacebook +3 | High | Solution | ||
| Car Fleet
#Array
#Stack
#Sorting | Medium | AmazonGoogle | Medium | Solution | ||
| Daily Temperatures
#Array
#Stack
#Monotonic Stack | Medium | AmazonGoogle +1 | High | Solution | ||
| Decode String
#String
#Stack
#Recursion | Medium | GoogleAmazon +1 | Medium | Solution | ||
| Evaluate Reverse Polish Notation
#Array
#Math
#Stack | Medium | AmazonLinkedIn | Medium | Solution | ||
| Implement Queue using Stack
#Stack | Medium | AmazonGoogle +1 | High | Solution | ||
| Implement Stack using Queues
#Stack | Medium | AmazonGoogle +1 | High | Solution | ||
| Maximum Area Rectangle in Binary Matrix
#Stack | Medium | AmazonGoogle +1 | High | Solution | ||
| Min Stack
#Stack
#Design | Medium | AmazonBloomberg +1 | High | Solution | ||
| Minimum Add to Make Parentheses Valid
#Stack | Medium | AmazonGoogle +1 | High | Solution | ||
| Minimum Element in Stack in O
#Stack | Medium | AmazonGoogle +1 | High | Solution | ||
| Minimum Element in Stack with Extra Space
#Stack | Medium | AmazonGoogle +1 | High | Solution | ||
| Next Largest Element to Left
#Stack | Medium | AmazonGoogle +1 | High | Solution | ||
| Next Largest Element to Right
#Stack | Medium | AmazonGoogle +1 | High | Solution | ||
| Next Smallest Element to Left
#Stack | Medium | AmazonGoogle +1 | High | Solution | ||
| Next Smallest Element to Right
#Stack | Medium | AmazonGoogle +1 | High | Solution | ||
| Remove All Occurrences of a Substring
#Stack | Medium | AmazonGoogle +1 | High | Solution | ||
| Remove K Digits
#String
#Stack
#Greedy | Medium | GoogleFacebook | Medium | Solution | ||
| Simplify Path
#String
#Stack | Medium | FacebookAirbnb +1 | Medium | Solution |
Binary Search
Halve the search space each step to find an element or boundary in O(log n).
| Problem | Difficulty | Companies | Frequency | Solution | Link | |
|---|---|---|---|---|---|---|
| Binary Search
#Array
#Binary Search | Easy | AmazonGoogle +1 | High | Solution | ||
| Binary Search on Sorted Array
#Binary Search | Medium | AmazonGoogle +1 | High | Solution | ||
| Capacity to Ship Packages Within D Days
#Array
#Binary Search | Medium | AmazonFacebook +1 | High | Solution | ||
| Common Elements from 3 Sorted Arrays
#Array | Medium | AmazonGoogle +1 | High | Solution | ||
| Count the number of occurrences of the element in a sorted array.
#Binary Search | Medium | AmazonGoogle +1 | High | Solution | ||
| Find Ciel of an Element in a Sorted Array
#Binary Search | Medium | AmazonGoogle +1 | High | Solution | ||
| Find Floor of an Element in a Sorted Array
#Binary Search | Medium | AmazonGoogle +1 | High | Solution | ||
| Find Maximum element in Bitonic Array
#Binary Search | Medium | AmazonGoogle +1 | High | Solution | ||
| Find Minimum in Rotated Sorted Array
#Array
#Binary Search | Medium | AmazonMicrosoft | High | Solution | ||
| Find Peak Element
#Array
#Binary Search | Medium | GoogleFacebook | Medium | Solution | ||
| Find the First and Last Occurrence of the Element in the Sorted Array
#Binary Search | Medium | AmazonGoogle +1 | High | Solution | ||
| Find the position of an element in an infinite sorted array.
#Binary Search | Medium | AmazonGoogle +1 | High | Solution | ||
| First Bad Version
#Binary Search | Medium | AmazonGoogle +1 | High | Solution | ||
| Index of the first 1 in a Infinite Binary Sorted Array
#Binary Search | Medium | AmazonGoogle +1 | High | Solution | ||
| Koko Eating Bananas
#Array
#Binary Search | Medium | FacebookAmazon | Medium | Solution | ||
| Magic Index
#Array | Medium | AmazonGoogle +1 | High | Solution | ||
| Merge sorted arrays
#Array | Medium | AmazonGoogle +1 | High | Solution | ||
| Minimum Difference Element in a Sorted Array
#Binary Search | Medium | AmazonGoogle +1 | High | Solution | ||
| Next Alphabetical Element in Sorted Array of Characters
#Binary Search | Medium | AmazonGoogle +1 | High | Solution | ||
| Next Greatest Element in Sorted Array
#Binary Search | Medium | AmazonGoogle +1 | High | Solution | ||
| Next Smallest Element in Sorted Array
#Binary Search | Medium | AmazonGoogle +1 | High | Solution | ||
| Pow(x, n)
#Binary Search | Medium | AmazonGoogle +1 | High | Solution | ||
| Row with Maximum number of 1's
#Binary Search | Medium | AmazonGoogle +1 | High | Solution | ||
| Search a 2D Matrix
#Array
#Binary Search
#Matrix | Medium | AmazonMicrosoft +1 | High | Solution | ||
| Search an Element in Bitonic Array
#Binary Search | Medium | AmazonGoogle +1 | High | Solution | ||
| Search in a Nearly Sorted Array
#Binary Search | Medium | AmazonGoogle +1 | High | Solution | ||
| Search in Rotated Sorted Array
#Array
#Binary Search | Medium | AmazonFacebook +2 | High | Solution | ||
| Search in Rotated Sorted Array II
#Binary Search | Medium | AmazonGoogle +1 | High | Solution | ||
| Search Insert Position
#Binary Search | Medium | AmazonGoogle +1 | High | Solution | ||
| Single Element in a Sorted Array
#Binary Search | Medium | AmazonGoogle +1 | High | Solution | ||
| Smallest Missing Number in sorted array
#Binary Search | Medium | AmazonGoogle +1 | High | Solution | ||
| Time Based Key-Value Store
#Hash Map
#Binary Search
#Design | Medium | GoogleAirbnb +1 | Medium | Solution | ||
| Median of Two Sorted Arrays
#Array
#Binary Search
#Divide and Conquer | Hard | GoogleAmazon +3 | High | Solution | ||
| Split Array Largest Sum
#Array
#Binary Search
#Dynamic Programming | Hard | GoogleFacebook +1 | Medium | Solution |
Prefix Sum
Precompute cumulative sums to answer range queries in O(1).
| Problem | Difficulty | Companies | Frequency | Solution | Link | |
|---|---|---|---|---|---|---|
| Find Pivot Index
#Array
#Prefix Sum | Easy | AmazonGoogle | High | Solution | ||
| Range Sum Query - Immutable
#Array
#Design
#Prefix Sum | Easy | Amazon | Medium | Solution | ||
| Running Sum of 1D Array
#Array
#Prefix Sum | Easy | AmazonApple | Medium | Solution | ||
| Contiguous Array
#Array
#Hash Map
#Prefix Sum | Medium | Facebook | Medium | Solution | ||
| Max Chunks To Make Sorted
#Array | Medium | AmazonGoogle +1 | High | Solution | ||
| Max Chunks To Make Sorted II
#Array | Medium | AmazonGoogle +1 | High | Solution | ||
| Minimum Average Difference
#Array
#Prefix Sum | Medium | Amazon | Low | Solution | ||
| Product of Array Except Self
#Array
#Prefix Product | Medium | AmazonFacebook +2 | High | Solution | ||
| Subarray Sum Equals K
#Array
#Hash Map
#Prefix Sum | Medium | FacebookGoogle +3 | High | Solution |
Linked List
Pointer manipulation for in-place list operations without extra memory.
| Problem | Difficulty | Companies | Frequency | Solution | Link | |
|---|---|---|---|---|---|---|
| Linked List Cycle
#Linked List
#Two Pointers
#Hash Table | Easy | AmazonMicrosoft +1 | High | Solution | ||
| Merge Two Sorted Lists
#Linked List
#Recursion | Easy | AmazonMicrosoft +1 | High | Solution | ||
| Middle of the Linked List
#Linked List | Easy | AmazonGoogle +1 | High | Solution | ||
| Palindrome Linked List
#Linked List
#Two Pointers
#Stack | Easy | AmazonFacebook +2 | High | Solution | ||
| Remove Duplicates from Sorted List
#Linked List | Easy | AmazonGoogle +1 | High | Solution | ||
| Remove Duplicates from Sorted List - II
#Linked List | Easy | AmazonGoogle +1 | High | Solution | ||
| Reverse Linked List
#Linked List
#Recursion | Easy | AmazonFacebook +2 | High | Solution | ||
| Add Two Numbers
#Linked List
#Math
#Recursion | Medium | AmazonMicrosoft +3 | High | Solution | ||
| Add Two Numbers II
#Linked List | Medium | AmazonGoogle +1 | High | Solution | ||
| Add Two Numbers Represented in Linked List
#Linked List | Medium | AmazonGoogle +1 | High | Solution | ||
| Convert Binary Number in a Linked List to Integer
#Linked List | Medium | AmazonGoogle +1 | High | Solution | ||
| Copy List with Random Pointer
#Hash Table
#Linked List | Medium | AmazonMicrosoft +2 | High | Solution | ||
| Find the intersection of two linked lists
#Linked List | Medium | AmazonGoogle +1 | High | Solution | ||
| Linked List Cycle II
#Linked List | Medium | AmazonGoogle +1 | High | Solution | ||
| Odd Even Linked List
#Linked List | Medium | AmazonGoogle +1 | High | Solution | ||
| Partition List
#Linked List | Medium | AmazonGoogle +1 | High | Solution | ||
| Remove Nth Node From End of List
#Linked List
#Two Pointers | Medium | AmazonMicrosoft +2 | High | Solution | ||
| Reorder List
#Linked List
#Two Pointers
#Stack | Medium | AmazonFacebook | Medium | Solution | ||
| Reverse a Linked List in groups of given size k
#Linked List | Medium | AmazonGoogle +1 | High | Solution | ||
| Reverse Linked List II
#Linked List | Medium | AmazonGoogle +1 | High | Solution | ||
| Rotate List
#Linked List
#Two Pointers | Medium | AmazonMicrosoft | Medium | Solution | ||
| Sort List
#Linked List | Medium | AmazonGoogle +1 | High | Solution | ||
| Swap Nodes in Pairs
#Linked List
#Recursion | Medium | AmazonMicrosoft +1 | Medium | Solution | ||
| Reverse Nodes in k-Group
#Linked List
#Recursion | Hard | AmazonMicrosoft +2 | High | Solution |
Trees / DFS
Recursive and iterative depth-first traversal for tree structure problems.
| Problem | Difficulty | Companies | Frequency | Solution | Link | |
|---|---|---|---|---|---|---|
| Diameter of Binary Tree
#Tree
#DFS
#Binary Tree | Easy | FacebookAmazon +1 | High | Solution | ||
| Invert Binary Tree
#Tree
#DFS
#BFS | Easy | AmazonApple +1 | High | Solution | ||
| Maximum Depth of Binary Tree
#Tree
#DFS
#BFS | Easy | AmazonLinkedIn | High | Solution | ||
| Same Tree
#Tree
#Depth-First Search
#Breadth-First Search | Easy | AmazonGoogle +1 | High | Solution | ||
| Subtree of Another Tree
#Tree
#Depth-First Search
#String Matching | Easy | AmazonFacebook +1 | High | Solution | ||
| Symmetric Tree
#Tree
#DFS
#BFS | Easy | AmazonMicrosoft +1 | High | Solution | ||
| Binary Tree Right Side View
#Tree
#DFS
#BFS | Medium | FacebookAmazon +1 | High | Solution | ||
| Construct Binary Tree from Preorder and Inorder Traversal
#Array
#Hash Table
#Divide and Conquer | Medium | AmazonMicrosoft +1 | Medium | Solution | ||
| Count Good Nodes in Binary Tree
#Tree
#DFS
#BFS | Medium | FacebookAmazon | Medium | Solution | ||
| Flatten Binary Tree to Linked List
#Linked List
#Stack
#Tree | Medium | AmazonMicrosoft +1 | Medium | Solution | ||
| Kth Smallest Element in a BST
#Tree
#DFS
#BST | Medium | AmazonFacebook +1 | High | Solution | ||
| Lowest Common Ancestor of a BST
#Tree
#DFS
#BST | Medium | AmazonFacebook +1 | High | Solution | ||
| Path Sum II
#Backtracking
#Tree
#DFS | Medium | AmazonMicrosoft +1 | Medium | Solution | ||
| Populating Next Right Pointers in Each Node
#Linked List
#Tree
#DFS | Medium | FacebookAmazon +1 | Medium | Solution | ||
| Sum Root to Leaf Numbers
#Tree
#DFS
#BFS | Medium | AmazonGoogle +1 | Medium | Solution | ||
| Validate Binary Search Tree
#Tree
#DFS
#BST | Medium | AmazonBloomberg +2 | High | Solution | ||
| Binary Tree Maximum Path Sum
#Tree
#DFS
#DP | Hard | AmazonFacebook +2 | High | Solution | ||
| Serialize and Deserialize Binary Tree
#Tree
#DFS
#BFS | Hard | GoogleAmazon +2 | Medium | Solution |
Queue / BFS
Level-by-level traversal for shortest paths and layer-based problems.
| Problem | Difficulty | Companies | Frequency | Solution | Link | |
|---|---|---|---|---|---|---|
| 01 Matrix
#Array
#BFS
#Matrix | Medium | FacebookAmazon +1 | High | Solution | ||
| Binary Tree Level Order Traversal
#Tree
#BFS | Medium | AmazonFacebook +1 | High | Solution | ||
| Jump Game III
#Array
#DFS
#BFS | Medium | AmazonGoogle | Medium | Solution | ||
| Minimum Genetic Mutation
#Hash Table
#String
#BFS | Medium | GoogleAmazon | Medium | Solution | ||
| Number of Islands
#Array
#DFS
#BFS | Medium | AmazonGoogle +2 | High | Solution | ||
| Open the Lock
#Array
#Hash Table
#BFS | Medium | GoogleAmazon | Medium | Solution | ||
| Rotting Oranges
#Array
#BFS
#Matrix | Medium | AmazonGoogle | High | Solution | ||
| Shortest Path in Binary Matrix
#Array
#BFS
#Matrix | Medium | AmazonGoogle +1 | Medium | Solution | ||
| Walls and Gates
Premium
#Array
#BFS
#Matrix | Medium | FacebookAmazon | Medium | Solution | ||
| Word Ladder
#Hash Set
#BFS
#String | Hard | AmazonFacebook +2 | Medium | Solution |
Heap / Priority Queue
Efficiently track the k-th largest/smallest element or merge sorted sequences.
| Problem | Difficulty | Companies | Frequency | Solution | Link | |
|---|---|---|---|---|---|---|
| Connect Ropes to Minimize the Cost
#Heap
#Priority Queue | Medium | AmazonGoogle +1 | High | Solution | ||
| Find K Closest Elements
#Heap
#Priority Queue | Medium | AmazonGoogle +1 | High | Solution | ||
| Find K Pairs with Smallest Sums
#Array
#Heap | Medium | AmazonGoogle +1 | Medium | Solution | ||
| K Closest Points to Origin
#Array
#Math
#Divide and Conquer | Medium | FacebookAmazon +2 | High | Solution | ||
| Kth Largest Element in a Stream
#Heap
#Priority Queue | Medium | AmazonGoogle +1 | High | Solution | ||
| Kth Largest Element in an Array
#Array
#Heap
#Sorting | Medium | FacebookAmazon +2 | High | Solution | ||
| Minimum Cost to Connect Sticks
Premium
#Array
#Greedy
#Heap | Medium | AmazonFacebook | Medium | Solution | ||
| Reorganize String
#Hash Table
#String
#Greedy | Medium | AmazonGoogle +1 | Medium | Solution | ||
| Sort an Almost Sorted Array
#Heap
#Priority Queue | Medium | AmazonGoogle +1 | High | Solution | ||
| Task Scheduler
#Array
#Heap
#Greedy | Medium | FacebookAmazon | Medium | Solution | ||
| The sum of Elements between k1 smallest and k2 smallest numbers
#Heap
#Priority Queue | Medium | AmazonGoogle +1 | High | Solution | ||
| Top K Frequent Words
#Hash Table
#String
#Trie | Medium | AmazonBloomberg +1 | Medium | Solution | ||
| Find Median from Data Stream
#Two Heaps
#Design
#Sorting | Hard | AmazonMicrosoft +1 | High | Solution | ||
| Merge K Sorted Lists
#Linked List
#Heap
#Divide and Conquer | Hard | AmazonFacebook +2 | High | Solution |
Backtracking
Explore all possibilities recursively, pruning invalid branches early.
| Problem | Difficulty | Companies | Frequency | Solution | Link | |
|---|---|---|---|---|---|---|
| Longest Valid Parentheses
#String | Easy | AmazonGoogle +1 | High | Solution | ||
| Combination Sum
#Array
#Backtracking | Medium | AmazonFacebook +1 | High | Solution | ||
| Combination Sum II
#Array
#Backtracking | Medium | AmazonAdobe | Medium | Solution | ||
| Find all permutations of a given string without duplicates
#String | Medium | AmazonGoogle +1 | High | Solution | ||
| Find all permutations of a string
#String | Medium | AmazonGoogle +1 | High | Solution | ||
| Generate Parentheses
#String
#Dynamic Programming
#Backtracking | Medium | AmazonGoogle +2 | High | Solution | ||
| Letter Combinations of a Phone Number
#Hash Table
#String
#Backtracking | Medium | AmazonFacebook +3 | High | Solution | ||
| Next Permutation
#Array | Medium | AmazonGoogle +1 | High | Solution | ||
| Palindrome Partitioning
#String
#Dynamic Programming
#Backtracking | Medium | AmazonFacebook +1 | Medium | Solution | ||
| Permutations
#Array
#Backtracking | Medium | LinkedInMicrosoft +1 | High | Solution | ||
| Subsets
#Array
#Backtracking
#Bit Manipulation | Medium | FacebookAmazon +1 | High | Solution | ||
| Subsets II
#Array
#Backtracking
#Bit Manipulation | Medium | FacebookAmazon | Medium | Solution | ||
| Word Search
#Array
#Matrix
#Backtracking | Medium | AmazonFacebook +2 | High | Solution | ||
| N-Queens
#Array
#Backtracking | Hard | AmazonMicrosoft | Medium | Solution |
Graphs
DFS and BFS on adjacency lists for connectivity, cycles, and path problems.
| Problem | Difficulty | Companies | Frequency | Solution | Link | |
|---|---|---|---|---|---|---|
| All Paths From Source to Target
#Backtracking
#DFS
#BFS | Medium | AmazonFacebook +1 | Medium | Solution | ||
| Cheapest Flights Within K Stops
#Dynamic Programming
#DFS
#BFS | Medium | AmazonGoogle +1 | High | Solution | ||
| Clone Graph
#Graph
#DFS
#BFS | Medium | FacebookAmazon +1 | High | Solution | ||
| Find Eventual Safe States
#DFS
#BFS
#Graph | Medium | GoogleAmazon | Medium | Solution | ||
| Graph Valid Tree
Premium
#Depth-First Search
#Breadth-First Search
#Union Find | Medium | GoogleFacebook +2 | High | Solution | ||
| Minimum Height Trees
#DFS
#BFS
#Graph | Medium | GoogleAmazon | Medium | Solution | ||
| Network Delay Time
#DFS
#BFS
#Graph | Medium | AmazonGoogle +1 | Medium | Solution | ||
| Number of Connected Components in Undirected Graph
Premium
#Graph
#DFS
#Union Find | Medium | LinkedInGoogle +1 | Medium | Solution | ||
| Pacific Atlantic Water Flow
#Graph
#DFS
#BFS | Medium | GoogleFacebook +1 | Medium | Solution | ||
| Surrounded Regions
#Array
#DFS
#BFS | Medium | GoogleFacebook +1 | Medium | Solution |
Dynamic Programming
Break problems into overlapping subproblems and build up solutions bottom-up.
| Problem | Difficulty | Companies | Frequency | Solution | Link | |
|---|---|---|---|---|---|---|
| Best Time to Buy and Sell Stock
#Array
#Dynamic Programming | Easy | AmazonFacebook +3 | High | Solution | ||
| Climbing Stairs
#DP
#Math
#Memoization | Easy | AmazonAdobe +1 | High | Solution | ||
| Min Cost Climbing Stairs
#Array
#Dynamic Programming | Easy | AmazonGoogle +1 | High | Solution | ||
| Best Time to Buy and Sell Stock with Cooldown
#Array
#Dynamic Programming | Medium | AmazonGoogle | Medium | Solution | ||
| Best Time to Buy and Sell Stock with Transaction Fee
#Array
#Dynamic Programming
#Greedy | Medium | AmazonGoogle | Medium | Solution | ||
| Coin Change
#Array
#DP
#BFS | Medium | AmazonGoogle +2 | High | Solution | ||
| Decode Ways
#String
#DP | Medium | AmazonFacebook +1 | High | Solution | ||
| House Robber
#Array
#DP | Medium | AmazonGoogle +1 | High | Solution | ||
| House Robber II
#Array
#Dynamic Programming | Medium | AmazonGoogle +1 | High | Solution | ||
| Integer Break
#Math
#Dynamic Programming | Medium | Google | Low | Solution | ||
| Interleaving String
#String
#Dynamic Programming
#BFS | Medium | AmazonGoogle +1 | Medium | Solution | ||
| Longest Common Subsequence
#String
#DP | Medium | GoogleAmazon +1 | High | Solution | ||
| Longest Increasing Subsequence
#Array
#DP
#Binary Search | Medium | GoogleAmazon +1 | High | Solution | ||
| Longest Palindromic Substring
#String
#Dynamic Programming | Medium | AmazonMicrosoft +2 | High | Solution | ||
| Maximum Product Subarray
#Array
#Dynamic Programming | Medium | AmazonGoogle +4 | High | Solution | ||
| Maximum Subarray
#Array
#DP
#Divide and Conquer | Medium | AmazonLinkedIn +2 | High | Solution | ||
| Minimum Path Sum
#Array
#Dynamic Programming
#Matrix | Medium | AmazonGoogle +1 | High | Solution | ||
| Palindromic Substrings
#String
#Dynamic Programming | Medium | FacebookAmazon +1 | High | Solution | ||
| Partition Equal Subset Sum
#Array
#Dynamic Programming | Medium | AmazonFacebook +1 | High | Solution | ||
| Perfect Squares
#Math
#Dynamic Programming
#BFS | Medium | GoogleAmazon | Medium | Solution | ||
| Target Sum
#Array
#Dynamic Programming
#Backtracking | Medium | FacebookAmazon +1 | High | Solution | ||
| Triangle
#Array
#Dynamic Programming | Medium | AmazonApple | Medium | Solution | ||
| Unique Paths
#Math
#DP
#Combinatorics | Medium | AmazonGoogle +1 | High | Solution | ||
| Word Break
#String
#DP
#Hash Set | Medium | AmazonGoogle +2 | High | Solution | ||
| Edit Distance
#String
#DP | Hard | GoogleAmazon +2 | Medium | Solution | ||
| Regular Expression Matching
#String
#Dynamic Programming
#Recursion | Hard | GoogleFacebook +2 | Medium | Solution |
Greedy
Make the locally optimal choice at each step to achieve a globally optimal solution.
| Problem | Difficulty | Companies | Frequency | Solution | Link | |
|---|---|---|---|---|---|---|
| Gas Station
#Array
#Greedy | Medium | AmazonUber +1 | Medium | Solution | ||
| Jump Game
#Array
#Greedy
#DP | Medium | AmazonMicrosoft +1 | High | Solution | ||
| Jump Game II
#Array
#Greedy
#DP | Medium | AmazonGoogle +1 | High | Solution | ||
| Meeting Rooms II
Premium
#Array
#Greedy
#Sorting | Medium | FacebookAmazon +4 | High | Solution | ||
| Minimum Number of Arrows to Burst Balloons
#Array
#Greedy
#Sorting | Medium | MicrosoftAmazon | Medium | Solution | ||
| Non-overlapping Intervals
#Array
#Greedy
#Dynamic Programming | Medium | GoogleFacebook | High | Solution | ||
| Queue Reconstruction by Height
#Array
#Greedy
#Sorting | Medium | GoogleFacebook | Medium | Solution | ||
| Candy
#Array
#Greedy | Hard | AmazonGoogle | Medium | Solution |
Intervals
Merge, insert, and count overlapping intervals after sorting by start time.
| Problem | Difficulty | Companies | Frequency | Solution | Link | |
|---|---|---|---|---|---|---|
| Meeting Rooms
Premium
#Array
#Sorting | Easy | FacebookAmazon +2 | High | Solution | ||
| Insert Interval
#Array | Medium | LinkedInGoogle +2 | High | Solution | ||
| Merge Intervals
#Array
#Sorting | Medium | FacebookAmazon +3 | High | Solution | ||
| Minimum Interval to Include Each Query
#Array
#Binary Search
#Line Sweep | Hard | GoogleAmazon | Low | Solution |
Matrix
Navigate 2D grids with DFS/BFS, rotation, spiral traversal, and flood fill.
| Problem | Difficulty | Companies | Frequency | Solution | Link | |
|---|---|---|---|---|---|---|
| Count Negative Numbers in a Sorted Matrix
#Array
#Binary Search
#Matrix | Easy | AmazonGoogle | Medium | Solution | ||
| Game of Life
#Array
#Matrix
#Simulation | Medium | GoogleAmazon +2 | Medium | Solution | ||
| Maximal Square
#Array
#Dynamic Programming
#Matrix | Medium | FacebookAmazon +2 | High | Solution | ||
| Rotate Image
#Array
#Matrix
#Math | Medium | AmazonMicrosoft +1 | High | Solution | ||
| Search a 2D Matrix II
#Array
#Binary Search
#Divide and Conquer | Medium | AmazonApple +2 | High | Solution | ||
| Set Matrix Zeroes
#Array
#Matrix | Medium | AmazonMicrosoft +1 | High | Solution | ||
| Spiral Matrix
#Array
#Matrix
#Simulation | Medium | AmazonMicrosoft +2 | High | Solution |
Bit Manipulation
Use bitwise operations to solve XOR, subset, and number theory problems.
| Problem | Difficulty | Companies | Frequency | Solution | Link | |
|---|---|---|---|---|---|---|
| Counting Bits
#DP
#Bit Manipulation | Easy | GoogleFacebook | High | Solution | ||
| Missing Number
#Array
#Math
#Bit Manipulation | Easy | MicrosoftAmazon | High | Solution | ||
| Number of 1 Bits
#Divide and Conquer
#Bit Manipulation | Easy | AppleMicrosoft +1 | High | Solution | ||
| Power of Two
#Math
#Bit Manipulation
#Recursion | Easy | GoogleApple | Medium | Solution | ||
| Reverse Bits
#Divide and Conquer
#Bit Manipulation | Easy | AppleAmazon | Medium | Solution | ||
| Single Number
#Array
#Bit Manipulation | Easy | AmazonApple +1 | High | Solution | ||
| Single Number II
#Array
#Bit Manipulation | Medium | AmazonFacebook | Medium | Solution | ||
| Sum of Two Integers
#Math
#Bit Manipulation | Medium | FacebookAmazon +1 | Medium | Solution |
Topological Sort
Linear ordering of vertices in a DAG — essential for dependency problems.
| Problem | Difficulty | Companies | Frequency | Solution | Link | |
|---|---|---|---|---|---|---|
| Course Schedule
#Graph
#DFS
#BFS | Medium | AmazonFacebook +2 | High | Solution | ||
| Course Schedule II
#Graph
#DFS
#BFS | Medium | FacebookAmazon +1 | High | Solution | ||
| Parallel Courses
Premium
#Graph
#Topological Sort
#BFS | Medium | AmazonGoogle | Medium | Solution | ||
| Sequence Reconstruction
Premium
#Array
#Graph
#Topological Sort | Medium | GoogleSnapchat | Low | Solution | ||
| Alien Dictionary
Premium
#Array
#String
#Graph | Hard | FacebookAmazon +3 | High | Solution |
Union Find
Disjoint set union for grouping, connectivity, and cycle detection.
| Problem | Difficulty | Companies | Frequency | Solution | Link | |
|---|---|---|---|---|---|---|
| Accounts Merge
#Graph
#Union Find
#DFS | Medium | FacebookAmazon +1 | Medium | Solution | ||
| Most Stones Removed with Same Row or Column
#Hash Table
#DFS
#Union-Find | Medium | FacebookAmazon | Medium | Solution | ||
| Number of Provinces
#DFS
#BFS
#Union-Find | Medium | AmazonFacebook +1 | High | Solution | ||
| Redundant Connection
#Graph
#Union Find
#DFS | Medium | GoogleAmazon | Medium | Solution | ||
| Satisfiability of Equality Equations
#Array
#String
#Union-Find | Medium | GoogleAmazon | Medium | Solution | ||
| Swim in Rising Water
#Array
#Binary Search
#DFS | Hard | GoogleAmazon | Medium | Solution |
Trie
Prefix tree for efficient string search, autocomplete, and word matching.
| Problem | Difficulty | Companies | Frequency | Solution | Link | |
|---|---|---|---|---|---|---|
| Design Add and Search Words Data Structure
#Design
#Trie
#DFS | Medium | FacebookBloomberg | Medium | Solution | ||
| Implement Trie (Prefix Tree)
#Design
#Trie | Medium | AmazonGoogle +2 | High | Solution | ||
| Longest Word in Dictionary
#Array
#Hash Table
#String | Medium | Google | Low | Solution | ||
| Replace Words
#Array
#Hash Table
#String | Medium | FacebookAmazon | Medium | Solution | ||
| Word Search II
#Array
#String
#Backtracking | Hard | AmazonMicrosoft +1 | Medium | Solution |
Monotonic Stack
Maintain a sorted stack to find next/previous greater or smaller elements in O(n).
| Problem | Difficulty | Companies | Frequency | Solution | Link | |
|---|---|---|---|---|---|---|
| Next Greater Element I
#Array
#Hash Map
#Stack | Easy | Apple | Medium | Solution | ||
| 132 Pattern
#Array
#Binary Search
#Stack | Medium | GoogleAmazon +1 | Medium | Solution | ||
| Online Stock Span
#Stack
#Design
#Monotonic Stack | Medium | AmazonMicrosoft | Medium | Solution | ||
| Remove Duplicate Letters
#String
#Stack
#Greedy | Medium | GoogleLyft | Medium | Solution | ||
| Stock Span Problem
#Stack | Medium | AmazonGoogle +1 | High | Solution | ||
| Sum of Subarray Minimums
#Array
#Dynamic Programming
#Stack | Medium | GoogleAmazon | Medium | Solution | ||
| Largest Rectangle in Histogram
#Array
#Stack
#Monotonic Stack | Hard | AmazonGoogle +1 | High | Solution |