The oneby7 147 DSA sheet
These 147 problems cover every topic on the roadmap. At three problems a day, the sheet takes 7 weeks.
01Foundations1
- Fibonacci NumberRecursion basicsSolveEasy
02Arrays and Hashing13
- Two SumHash map lookupsSolveEasy
- Contains DuplicateHash map lookupsSolveEasy
- Valid AnagramHash map lookupsSolveEasy
- Group AnagramsHash map lookupsSolveMedium
- Longest Consecutive SequenceHash map lookupsSolveMedium
- Top K Frequent ElementsCounting and votingSolveMedium
- Majority ElementCounting and votingSolveEasy
- Best Time to Buy and Sell StockOne pass with running stateSolveEasy
- Maximum SubarrayOne pass with running stateSolveMedium
- Maximum Product SubarrayOne pass with running stateSolveMedium
- Product of Array Except SelfPrefix sumsSolveMedium
- Subarray Sum Equals KPrefix sumsSolveMedium
- Spiral MatrixWalking a matrixSolveMedium
04Bit Manipulation5
- Single NumberXOR tricksSolveEasy
- Missing NumberXOR tricksSolveEasy
- Number of 1 BitsCounting and shifting bitsSolveEasy
- Counting BitsCounting and shifting bitsSolveEasy
- Reverse BitsCounting and shifting bitsSolveEasy
05Strings1
- Longest Common PrefixString basicsSolveEasy
06Sorting1
- Sort an ArrayDivide-and-conquer sortsSolveMedium
07Two Pointers7
- Valid PalindromePointers from both endsSolveEasy
- Two Sum II - Input Array Is SortedPointers from both endsSolveMedium
- 3SumPointers from both endsSolveMedium
- Container With Most WaterPointers from both endsSolveMedium
- Trapping Rain WaterPointers from both endsSolveHard
- Sort ColorsRearranging in placeSolveMedium
- Next PermutationRearranging in placeSolveMedium
08Sliding Window7
- Longest Substring Without Repeating CharactersLongest or shortest windowSolveMedium
- Max Consecutive Ones IIILongest or shortest windowSolveMedium
- Longest Repeating Character ReplacementLongest or shortest windowSolveMedium
- Minimum Window SubstringLongest or shortest windowSolveHard
- Permutation in StringFixed-size windowSolveMedium
- Maximum Points You Can Obtain from CardsFixed-size windowSolveMedium
- Binary Subarrays With SumCounting windowsSolveMedium
09Stacks and Queues8
- Valid ParenthesesMatching and cancellingSolveEasy
- Min StackMatching and cancellingSolveMedium
- Evaluate Reverse Polish NotationMatching and cancellingSolveMedium
- Next Greater Element IMonotonic stackSolveEasy
- Daily TemperaturesMonotonic stackSolveMedium
- Car FleetMonotonic stackSolveMedium
- Largest Rectangle in HistogramMonotonic stackSolveHard
- Sliding Window MaximumMonotonic queueSolveHard
10Binary Search9
- Binary SearchSearching a sorted arraySolveEasy
- Search in Rotated Sorted ArraySearching a sorted arraySolveMedium
- Find Minimum in Rotated Sorted ArraySearching a sorted arraySolveMedium
- Find Peak ElementSearching a sorted arraySolveMedium
- Sqrt(x)Searching the answerSolveEasy
- Koko Eating BananasSearching the answerSolveMedium
- Magnetic Force Between Two BallsSearching the answerSolveMedium
- Split Array Largest SumSearching the answerSolveHard
- Median of Two Sorted ArraysPartition searchSolveHard
11Linked Lists11
- Middle of the Linked ListFast and slow pointersSolveEasy
- Linked List CycleFast and slow pointersSolveEasy
- Remove Nth Node From End of ListFast and slow pointersSolveMedium
- Linked List Cycle IIFast and slow pointersSolveMedium
- Reverse Linked ListReversing and rewiringSolveEasy
- Merge Two Sorted ListsReversing and rewiringSolveEasy
- Reorder ListReversing and rewiringSolveMedium
- Add Two NumbersReversing and rewiringSolveMedium
- Copy List with Random PointerReversing and rewiringSolveMedium
- Reverse Nodes in k-GroupReversing and rewiringSolveHard
- LRU CacheA list and a map togetherSolveMedium
12Recursion and Backtracking10
- SubsetsGenerating every choiceSolveMedium
- PermutationsGenerating every choiceSolveMedium
- Subsets IIGenerating every choiceSolveMedium
- Combination SumGenerating every choiceSolveMedium
- Combination Sum IIGenerating every choiceSolveMedium
- Letter Combinations of a Phone NumberGenerating every choiceSolveMedium
- Generate ParenthesesGenerating every choiceSolveMedium
- Palindrome PartitioningGenerating every choiceSolveMedium
- Word SearchSearching with constraintsSolveMedium
- N-QueensSearching with constraintsSolveHard
13Binary Trees12
- Maximum Depth of Binary TreeDepth first: return a value upSolveEasy
- Invert Binary TreeDepth first: return a value upSolveEasy
- Same TreeDepth first: return a value upSolveEasy
- Subtree of Another TreeDepth first: return a value upSolveEasy
- Diameter of Binary TreeDepth first: return a value upSolveEasy
- Lowest Common Ancestor of a Binary TreeDepth first: return a value upSolveMedium
- Binary Tree Maximum Path SumDepth first: return a value upSolveHard
- Binary Tree Level Order TraversalBreadth first: level by levelSolveMedium
- Binary Tree Right Side ViewBreadth first: level by levelSolveMedium
- All Nodes Distance K in Binary TreeBreadth first: level by levelSolveMedium
- Construct Binary Tree from Preorder and Inorder TraversalBuilding and serializingSolveMedium
- Serialize and Deserialize Binary TreeBuilding and serializingSolveHard
14Binary Search Trees5
- Validate Binary Search TreeUsing the orderingSolveMedium
- Kth Smallest Element in a BSTUsing the orderingSolveMedium
- Lowest Common Ancestor of a Binary Search TreeUsing the orderingSolveMedium
- Delete Node in a BSTUsing the orderingSolveMedium
- Recover Binary Search TreeUsing the orderingSolveMedium
15Heaps7
- Kth Largest Element in a StreamTop KSolveEasy
- Kth Largest Element in an ArrayTop KSolveMedium
- K Closest Points to OriginTop KSolveMedium
- Last Stone WeightSimulating with a heapSolveEasy
- Task SchedulerSimulating with a heapSolveMedium
- Find Median from Data StreamTwo heapsSolveHard
- Merge k Sorted ListsMerging k sorted listsSolveHard
16Tries3
- Implement Trie (Prefix Tree)Prefix treesSolveMedium
- Design Add and Search Words Data StructurePrefix treesSolveMedium
- Word Search IIPrefix treesSolveHard
17Graphs11
- Flood FillGrids as graphsSolveEasy
- Number of IslandsGrids as graphsSolveMedium
- Surrounded RegionsGrids as graphsSolveMedium
- Pacific Atlantic Water FlowGrids as graphsSolveMedium
- Rotting OrangesFewest steps with BFSSolveMedium
- 01 MatrixFewest steps with BFSSolveMedium
- Word LadderFewest steps with BFSSolveHard
- Clone GraphTraversing a graphSolveMedium
- Course ScheduleTopological sortSolveMedium
- Course Schedule IITopological sortSolveMedium
- Redundant ConnectionUnion-findSolveMedium
18Advanced Graphs5
- Network Delay TimeWeighted shortest pathsSolveMedium
- Path With Minimum EffortWeighted shortest pathsSolveMedium
- Cheapest Flights Within K StopsWeighted shortest pathsSolveMedium
- Swim in Rising WaterWeighted shortest pathsSolveHard
- Min Cost to Connect All PointsMinimum spanning treesSolveMedium
19Greedy6
- Jump GameThe best choice nowSolveMedium
- Jump Game IIThe best choice nowSolveMedium
- Gas StationThe best choice nowSolveMedium
- Partition LabelsThe best choice nowSolveMedium
- Valid Parenthesis StringThe best choice nowSolveMedium
- CandyThe best choice nowSolveHard
20Intervals4
- Merge IntervalsMerging and schedulingSolveMedium
- Insert IntervalMerging and schedulingSolveMedium
- Non-overlapping IntervalsMerging and schedulingSolveMedium
- Minimum Interval to Include Each QueryMerging and schedulingSolveHard
211-D Dynamic Programming9
- Climbing StairsTake it or skip itSolveEasy
- House RobberTake it or skip itSolveMedium
- House Robber IITake it or skip itSolveMedium
- Decode WaysTake it or skip itSolveMedium
- Word BreakTake it or skip itSolveMedium
- Longest Palindromic SubstringPalindromesSolveMedium
- Palindromic SubstringsPalindromesSolveMedium
- Longest Increasing SubsequenceIncreasing subsequencesSolveMedium
- Best Time to Buy and Sell Stock with CooldownBuying and selling with statesSolveMedium
222-D Dynamic Programming9
- Unique PathsPaths in a gridSolveMedium
- Longest Increasing Path in a MatrixPaths in a gridSolveHard
- Partition Equal Subset SumKnapsackSolveMedium
- Coin ChangeKnapsackSolveMedium
- Coin Change IIKnapsackSolveMedium
- Target SumKnapsackSolveMedium
- Longest Common SubsequenceTwo stringsSolveMedium
- Edit DistanceTwo stringsSolveMedium
- Burst BalloonsSplitting a rangeSolveHard
23String Matching1
- Find the Index of the First Occurrence in a StringPattern matchingSolveEasy