Blind 75
Revise 75 core DSA problems in Minutes
Questions (75)
Tap on any question to view the full solution
Two Sum
#1Use a hashmap to store complements and return indices when found.
Two Sum
#1Use a hashmap to store complements and return indices when found.
Best Time to Buy and Sell Stock
#2Track running minimum price and maximum profit in one pass.
Best Time to Buy and Sell Stock
#2Track running minimum price and maximum profit in one pass.
Contains Duplicate
#3Use a HashSet to detect duplicates quickly.
Contains Duplicate
#3Use a HashSet to detect duplicates quickly.
Maximum Subarray
#4Use Kadane's algorithm: track max ending here and global max.
Maximum Subarray
#4Use Kadane's algorithm: track max ending here and global max.
Product of Array Except Self
#5Compute prefix and suffix products to avoid division.
Product of Array Except Self
#5Compute prefix and suffix products to avoid division.
Maximum Product Subarray
#6Track both max and min products at each position, swapping when encountering negatives to handle sign flips.
Maximum Product Subarray
#6Track both max and min products at each position, swapping when encountering negatives to handle sign flips.
Find Minimum in Rotated Sorted Array
#7Use binary search comparing mid with right boundary to determine which half contains the minimum.
Find Minimum in Rotated Sorted Array
#7Use binary search comparing mid with right boundary to determine which half contains the minimum.
Search in Rotated Sorted Array
#8Identify which half is sorted, then determine if target lies in that sorted half to decide search direction.
Search in Rotated Sorted Array
#8Identify which half is sorted, then determine if target lies in that sorted half to decide search direction.
3Sum
#9Sort and use two pointers to find triplets summing to zero, skipping duplicates.
3Sum
#9Sort and use two pointers to find triplets summing to zero, skipping duplicates.
Container With Most Water
#10Two-pointer: move the shorter line inward to try larger area.
Container With Most Water
#10Two-pointer: move the shorter line inward to try larger area.
Sum of Two Integers
#11Add two integers using bitwise operations without using + or - operators.
Sum of Two Integers
#11Add two integers using bitwise operations without using + or - operators.
Number of 1 Bits
#12Count the number of set bits (1s) in the binary representation of an integer.
Number of 1 Bits
#12Count the number of set bits (1s) in the binary representation of an integer.
Counting Bits
#13Return array where result[i] is the number of 1 bits in binary representation of i.
Counting Bits
#13Return array where result[i] is the number of 1 bits in binary representation of i.
Missing Number
#14Find the missing number in array containing n distinct numbers from 0 to n.
Missing Number
#14Find the missing number in array containing n distinct numbers from 0 to n.
Reverse Bits
#15Reverse the bits of a 32-bit unsigned integer.
Reverse Bits
#15Reverse the bits of a 32-bit unsigned integer.
Climbing Stairs
#16Count distinct ways to climb n stairs when you can take 1 or 2 steps at a time.
Climbing Stairs
#16Count distinct ways to climb n stairs when you can take 1 or 2 steps at a time.
Coin Change
#17Find minimum coins needed to make amount using unbounded knapsack DP.
Coin Change
#17Find minimum coins needed to make amount using unbounded knapsack DP.
Longest Increasing Subsequence
#18Find length of longest strictly increasing subsequence using binary search on tails array.
Longest Increasing Subsequence
#18Find length of longest strictly increasing subsequence using binary search on tails array.
Longest Common Subsequence
#19Find longest common subsequence between two strings using 2D DP table.
Longest Common Subsequence
#19Find longest common subsequence between two strings using 2D DP table.
Word Break
#20Check if string can be segmented into dictionary words using DP.
Word Break
#20Check if string can be segmented into dictionary words using DP.
Combination Sum IV
#21Count number of combinations that sum to target where order matters (permutations).
Combination Sum IV
#21Count number of combinations that sum to target where order matters (permutations).
Unique Paths
#22Count unique paths from top-left to bottom-right in m×n grid moving only right/down.
Unique Paths
#22Count unique paths from top-left to bottom-right in m×n grid moving only right/down.
Jump Game
#23Determine if you can reach last index by tracking furthest reachable position greedily.
Jump Game
#23Determine if you can reach last index by tracking furthest reachable position greedily.
Clone Graph
#24Deep clone undirected graph using DFS/BFS with HashMap to track old→new node mapping.
Clone Graph
#24Deep clone undirected graph using DFS/BFS with HashMap to track old→new node mapping.
Course Schedule
#25Detect if course prerequisites form a cycle using topological sort or DFS cycle detection.
Course Schedule
#25Detect if course prerequisites form a cycle using topological sort or DFS cycle detection.
Pacific Atlantic Water Flow
#26Find cells that can flow to both oceans by doing reverse DFS from ocean borders.
Pacific Atlantic Water Flow
#26Find cells that can flow to both oceans by doing reverse DFS from ocean borders.
Number of Islands
#27Use DFS/BFS to flood-fill islands and count connected components.
Number of Islands
#27Use DFS/BFS to flood-fill islands and count connected components.
Longest Consecutive Sequence
#28Use HashSet to find sequence starts (no n-1) and count consecutive numbers in O(n).
Longest Consecutive Sequence
#28Use HashSet to find sequence starts (no n-1) and count consecutive numbers in O(n).
Alien Dictionary
#29Build graph from word order relationships and return topological sort of character ordering.
Alien Dictionary
#29Build graph from word order relationships and return topological sort of character ordering.
Graph Valid Tree
#30Check if graph is a valid tree: must be connected and have exactly n-1 edges (no cycles).
Graph Valid Tree
#30Check if graph is a valid tree: must be connected and have exactly n-1 edges (no cycles).
Serialize and Deserialize Binary Tree
#31Convert tree to string and back using BFS level-order or DFS pre-order traversal.
Serialize and Deserialize Binary Tree
#31Convert tree to string and back using BFS level-order or DFS pre-order traversal.
Invert Binary Tree
#32Recursively swap left and right children of every node.
Invert Binary Tree
#32Recursively swap left and right children of every node.
Maximum Depth of Binary Tree
#33Return max depth using DFS: 1 + max of left and right subtree depths.
Maximum Depth of Binary Tree
#33Return max depth using DFS: 1 + max of left and right subtree depths.
Diameter of Binary Tree
#34Track max diameter as sum of left and right heights at each node during DFS.
Diameter of Binary Tree
#34Track max diameter as sum of left and right heights at each node during DFS.
Balanced Binary Tree
#35Check if tree is height-balanced: at every node, left and right heights differ by at most 1.
Balanced Binary Tree
#35Check if tree is height-balanced: at every node, left and right heights differ by at most 1.
Same Tree
#36Recursively check if two trees have identical structure and node values.
Same Tree
#36Recursively check if two trees have identical structure and node values.
Subtree of Another Tree
#37Check if subRoot is identical to any subtree of root using isSameTree helper.
Subtree of Another Tree
#37Check if subRoot is identical to any subtree of root using isSameTree helper.
Lowest Common Ancestor of BST
#38Use BST property: if p and q split at node (one left, one right), that node is LCA.
Lowest Common Ancestor of BST
#38Use BST property: if p and q split at node (one left, one right), that node is LCA.
Binary Tree Level Order Traversal
#39Use BFS with queue to traverse tree level by level, collecting nodes at each level.
Binary Tree Level Order Traversal
#39Use BFS with queue to traverse tree level by level, collecting nodes at each level.
Binary Tree Right Side View
#40Use BFS to traverse level by level, collecting the rightmost node at each level.
Binary Tree Right Side View
#40Use BFS to traverse level by level, collecting the rightmost node at each level.
Count Good Nodes in Binary Tree
#41DFS tracking max value on path; count nodes where node.val >= maxSoFar.
Count Good Nodes in Binary Tree
#41DFS tracking max value on path; count nodes where node.val >= maxSoFar.
Validate Binary Search Tree
#42DFS with min/max bounds: left subtree < node < right subtree, recursively validate.
Validate Binary Search Tree
#42DFS with min/max bounds: left subtree < node < right subtree, recursively validate.
Kth Smallest Element in BST
#43Inorder traversal of BST gives sorted order; return kth element encountered.
Kth Smallest Element in BST
#43Inorder traversal of BST gives sorted order; return kth element encountered.
Construct Binary Tree from Preorder and Inorder Traversal
#44Use preorder's first element as root, find it in inorder to split left/right subtrees recursively.
Construct Binary Tree from Preorder and Inorder Traversal
#44Use preorder's first element as root, find it in inorder to split left/right subtrees recursively.
Binary Tree Maximum Path Sum
#45Track global max while DFS returns max single-path sum from each node.
Binary Tree Maximum Path Sum
#45Track global max while DFS returns max single-path sum from each node.
Implement Trie (Prefix Tree)
#46Build tree where each node has 26 children (a-z) and boolean flag for word endings.
Implement Trie (Prefix Tree)
#46Build tree where each node has 26 children (a-z) and boolean flag for word endings.
Design Add and Search Words Data Structure
#47Implement Trie with wildcard search using DFS to try all branches when '.' encountered.
Design Add and Search Words Data Structure
#47Implement Trie with wildcard search using DFS to try all branches when '.' encountered.
Word Search II
#48Build Trie from words, then DFS on board checking Trie nodes to find all matching words.
Word Search II
#48Build Trie from words, then DFS on board checking Trie nodes to find all matching words.
Merge K Sorted Lists
#49Use min-heap to always extract smallest element from k lists, adding next element from same list.
Merge K Sorted Lists
#49Use min-heap to always extract smallest element from k lists, adding next element from same list.
Merge Two Sorted Lists
#50Use dummy node and two pointers to build merged list by comparing and advancing smaller node.
Merge Two Sorted Lists
#50Use dummy node and two pointers to build merged list by comparing and advancing smaller node.
Reorder List
#51Find middle, reverse second half, then merge alternating nodes from both halves.
Reorder List
#51Find middle, reverse second half, then merge alternating nodes from both halves.
Remove Nth Node From End of List
#52Use two pointers with n-gap to find node before target, then skip target node.
Remove Nth Node From End of List
#52Use two pointers with n-gap to find node before target, then skip target node.
Linked List Cycle
#53Use Floyd's cycle detection: slow and fast pointers, if they meet there's a cycle.
Linked List Cycle
#53Use Floyd's cycle detection: slow and fast pointers, if they meet there's a cycle.
Reverse Linked List
#54Iteratively reverse pointers: track prev, current, and next nodes.
Reverse Linked List
#54Iteratively reverse pointers: track prev, current, and next nodes.
Linked List Cycle II
#55Use Floyd's algorithm: detect cycle, then find entry point by resetting one pointer to head.
Linked List Cycle II
#55Use Floyd's algorithm: detect cycle, then find entry point by resetting one pointer to head.
LRU Cache
#56Use HashMap + doubly linked list: map for O(1) access, DLL for O(1) eviction of LRU.
LRU Cache
#56Use HashMap + doubly linked list: map for O(1) access, DLL for O(1) eviction of LRU.
Min Stack
#57Use two stacks: one for values, one tracking minimum at each level.
Min Stack
#57Use two stacks: one for values, one tracking minimum at each level.
Valid Parentheses
#58Use stack to match closing brackets with their corresponding opening brackets.
Valid Parentheses
#58Use stack to match closing brackets with their corresponding opening brackets.
Generate Parentheses
#59Backtrack to generate valid combinations: add '(' if open < n, add ')' if close < open.
Generate Parentheses
#59Backtrack to generate valid combinations: add '(' if open < n, add ')' if close < open.
Daily Temperatures
#60Use monotonic decreasing stack to track indices, pop when warmer day found.
Daily Temperatures
#60Use monotonic decreasing stack to track indices, pop when warmer day found.
Car Fleet
#61Sort cars by position, calculate time to target, use stack to count fleets (slower cars create new fleets).
Car Fleet
#61Sort cars by position, calculate time to target, use stack to count fleets (slower cars create new fleets).
Evaluate Reverse Polish Notation
#62Use stack: push numbers, pop two operands on operator, compute and push result.
Evaluate Reverse Polish Notation
#62Use stack: push numbers, pop two operands on operator, compute and push result.
Implement Queue using Stacks
#63Use two stacks: push to stack1, pop/peek from stack2 (transfer when stack2 empty).
Implement Queue using Stacks
#63Use two stacks: push to stack1, pop/peek from stack2 (transfer when stack2 empty).
Implement Stack using Queues
#64Use one queue: on push, add element then rotate queue size-1 times to move it to front.
Implement Stack using Queues
#64Use one queue: on push, add element then rotate queue size-1 times to move it to front.
Design Twitter
#65Use HashMap for follows/tweets, merge k sorted lists with heap for news feed.
Design Twitter
#65Use HashMap for follows/tweets, merge k sorted lists with heap for news feed.
Find Median from Data Stream
#66Use two heaps: max-heap for smaller half, min-heap for larger half, balance sizes for O(1) median.
Find Median from Data Stream
#66Use two heaps: max-heap for smaller half, min-heap for larger half, balance sizes for O(1) median.
Kth Largest Element in a Stream
#67Maintain min-heap of size k; top element is always kth largest.
Kth Largest Element in a Stream
#67Maintain min-heap of size k; top element is always kth largest.
Top K Frequent Elements
#68Count frequencies with HashMap, use min-heap of size k to track top k elements.
Top K Frequent Elements
#68Count frequencies with HashMap, use min-heap of size k to track top k elements.
K Closest Points to Origin
#69Use max-heap of size k tracking distances; maintain k closest points by comparing squared distances.
K Closest Points to Origin
#69Use max-heap of size k tracking distances; maintain k closest points by comparing squared distances.
Meeting Rooms
#70Sort intervals by start time, check if any meeting starts before previous ends.
Meeting Rooms
#70Sort intervals by start time, check if any meeting starts before previous ends.
Meeting Rooms II
#71Sort by start time, use min-heap to track room end times, reuse rooms when available.
Meeting Rooms II
#71Sort by start time, use min-heap to track room end times, reuse rooms when available.
Non-overlapping Intervals
#72Sort by end time, greedily keep intervals that end earliest to minimize removals.
Non-overlapping Intervals
#72Sort by end time, greedily keep intervals that end earliest to minimize removals.
Insert Interval
#73Add non-overlapping intervals before newInterval, merge overlapping ones, add remaining intervals.
Insert Interval
#73Add non-overlapping intervals before newInterval, merge overlapping ones, add remaining intervals.
Merge Intervals
#74Sort intervals by start time, merge overlapping ones by extending end time.
Merge Intervals
#74Sort intervals by start time, merge overlapping ones by extending end time.
Move Zeroes
#75Use write pointer to compact non-zero elements, then fill remaining positions with zeros.
Move Zeroes
#75Use write pointer to compact non-zero elements, then fill remaining positions with zeros.