Learn how to split a linked list into k roughly equal parts in O(n) time using integer division and remainder math. A clean medium interview problem asked at Amazon and Facebook that tests linked list traversal and arithmetic reasoning.
Master reversing a subrange of a linked list in-place in a single pass. A classic interview problem at Facebook, Microsoft, and Amazon that tests your pointer manipulation skills and ability to handle complex multi-pointer state.
Master the three cases needed to insert a value into a sorted circular linked list correctly. A classic interview problem at Google, Facebook, and Amazon that tests your ability to handle circular structure edge cases and write bug-free pointer manipulation code.
Master reversing nodes in groups of k in a linked list — the classic hard interview problem asked at Amazon, Google, Facebook, and Microsoft. Learn both the elegant recursive solution and the iterative approach with clear pointer diagrams.
Master two optimal approaches to merge k sorted linked lists: min-heap for O(n log k) time and divide-and-conquer for O(n log k) with lower constant factors. A top-tier interview problem at Amazon, Google, Facebook, Microsoft, and Uber that tests your mastery of heaps and recursive merging.
Master bottom-up merge sort on a linked list for O(n log n) time and O(1) space — eliminating the O(log n) recursive stack. A hard interview problem at Amazon, Google, and Facebook that demonstrates deep understanding of merge sort and linked list mechanics.
Build an LRU Cache from scratch using a doubly linked list with sentinel nodes and a HashMap for O(1) get and put operations. The most frequently asked hard design problem at Amazon, Microsoft, Google, and Facebook — explained step by step with diagrams.
Next Permutation is not just an array problem — it is a test of systematic algorithmic thinking under pressure. Learn why you scan from the right, why you swap with the smallest larger element, and why the suffix is reversed rather than sorted. Includes full visual dry runs, the 4 most common bugs, and Python + JavaScript solutions.
Master Dijkstra's Dutch National Flag algorithm to sort 0s, 1s, and 2s in a single pass with O(1) space. Understand the three-pointer invariants, the critical bug most candidates make, and how this pattern unlocks a family of partition problems.
LC 78 is the gateway to every combination and permutation problem in FAANG interviews. Master all three approaches — backtracking, bitmask enumeration, and iterative cascading — with deep visual dry runs, real interview follow-ups, and line-by-line Python and JavaScript solutions.
LeetCode 739 — asked at Amazon, Google, and Meta. Find the number of days until a warmer temperature using a monotonic decreasing stack. Store indices not temperatures, pop when current day is warmer, and solve six related problems with the same O(n) pattern.
LeetCode 128 — asked at Google, Amazon, and Meta. Find the longest consecutive integer sequence in O(n) using a HashSet. Only start counting from numbers where num-1 is absent — each element is visited at most twice total, making an apparent O(n²) nested loop amortized O(n).
LeetCode 621 — asked at Google, Meta, and Amazon. Schedule tasks with a cooldown n to minimize total time. Use the greedy formula max(len(tasks), (max_count - 1) * (n + 1) + count_of_max) or simulate with a max-heap and queue — both O(tasks) time.
LeetCode 670 — asked at Meta and Amazon. Given a non-negative integer, swap at most one pair of digits to get the maximum value. Track the last occurrence of each digit, then greedily find the leftmost position where a larger digit appears later — O(n) time, O(1) space.
LeetCode 162 — asked at Google, Meta, and Amazon. Find any peak element in O(log n) using binary search on slope direction. If nums[mid] < nums[mid+1], a peak must exist in the right half — guaranteed by virtual negative infinity at both boundaries.
LeetCode 42 — one of the most asked hard problems at Amazon, Google, Microsoft, and Meta. Compute trapped rainwater using two pointers in O(n) time and O(1) space. The key: water at any position is min(left_max, right_max) minus the height. Move the pointer with the smaller max inward.
Master LeetCode 76 — the gold-standard Hard sliding window problem asked at Google, Meta, and Amazon. Learn the "formed" counter trick that reduces window validity checks from O(|t|) to O(1), trace through a full dry run, and avoid the five bugs that most often break this one.
LeetCode 4 is one of the most feared Hard problems in FAANG interviews. Learn exactly why the partition insight works, trace through a full binary search dry run, understand the five common bugs that cause silent wrong answers, and walk away with production-quality Python and JavaScript solutions.
LC 34 asks for the start and end index of a target in a sorted array. Solve it in O(log n) by running two separate binary searches — one for the left boundary and one for the right boundary. A top FAANG pattern.
Find the one non-duplicate element in O(log n) time by observing how pair indices shift after the singleton — a parity-based binary search that requires no XOR or extra space.
LC 410 asks you to split an array into k non-empty subarrays to minimize the largest subarray sum. Binary search on the answer range [max(nums), sum(nums)] and greedily count splits to check feasibility. O(n log(sum - max)) total time.
LC 1060 asks for the kth missing number in a sorted array. Binary search on the missing-count function: at index i, exactly nums[i] - nums[0] - i numbers are missing. Find the first index where this count >= k, then recover the answer. O(log n).
LC 786 asks for the kth smallest fraction a[i]/a[j] from a sorted prime array. Binary search on the fraction value [0.0, 1.0] and count fractions below mid using two pointers. O(n log(1/epsilon)) total. A hard binary search on value problem.
LC 981 implements a key-value store where each key can have values at different timestamps. set() in O(1), get(key, timestamp) in O(log n) using right-boundary binary search on the sorted timestamp list. A classic design + binary search interview problem.
LeetCode 494 Target Sum looks like sign-assignment but reduces to subset-sum count via a beautiful algebra trick. We derive the reduction, build the 1D DP, dry-run a tabulation, and discuss why this O(n * sum) solution beats 2^n brute force at FAANG.
LeetCode 44 Wildcard Matching is the classic 2D string DP question Meta and Google ask to test recurrence design under tricky base cases. We derive the dp[i][j] transitions for ? and *, dry-run a full table, and finish with a two-pointer optimization that drops memory to O(1).
LC 1905 Count Sub Islands asks how many islands in grid2 are subsets of islands in grid1. The critical trap is short-circuiting DFS on the first invalid cell — you must always complete the traversal to mark the whole island visited, while tracking validity separately.
Master Clone Graph (LeetCode 133): a FAANG favorite that tests BFS, DFS, graph traversal, hash map state, and cycle handling. We trace it step by step, derive the optimal pattern, and fortify you against the classic mistakes interviewers love to spot.
LeetCode 126 Word Ladder II asks for every shortest transformation path between two words. Master the layered BFS plus parent-map DFS pattern that survives the brutal time limits at Amazon, Google, and Facebook interviews.
LeetCode 785 Is Graph Bipartite asks whether you can 2-color a graph. Master the BFS and DFS coloring patterns, the disconnected-component handling, and the FAANG interview script that proves you understand bipartite theory.
LeetCode 399 Evaluate Division turns equations like A/B equals 2 into a weighted graph. Master the BFS, DFS, and Union Find solutions plus the FAANG-grade interview script.
Brick Wall teaches the insight of counting the complement — instead of minimizing bricks crossed, maximize gaps hit. Google uses this problem to test whether candidates can reframe a minimization problem as a maximization problem and solve it in O(n) with a frequency map.
LeetCode 653 (Easy) asks if any two nodes in a BST sum to k. Google, Facebook, and Amazon frequently use it as a warm-up to test whether you can combine DFS traversal with the Two Sum hash-set pattern.
Pick a uniformly random index of a target value without pre-processing, using reservoir sampling — an elegant streaming algorithm that appears in Google and Facebook interviews on probability and distributed systems.
LC 974 Subarray Sum Divisible by K counts subarrays whose sum is divisible by K using prefix remainders and a frequency hash map — the canonical prefix mod pattern tested at Google, Amazon, and Facebook.
LC 981 Time Based Key-Value Store pairs a hash map with binary search to retrieve the value associated with the largest timestamp not exceeding a query — a foundational design problem tested at Google, Amazon, and Facebook.
LeetCode 295 (Hard) — a FAANG favorite. Maintain a dynamic median from a live data stream using two heaps: a max-heap for the lower half and a min-heap for the upper half, achieving O(log n) per insert.
LeetCode 23 (Hard) — the most-asked heap problem at FAANG. Merge k sorted linked lists in O(N log k) using a min-heap that always tracks the smallest active head.
LeetCode 378 (Medium) — a Google and Amazon staple. Solve k-th smallest in a row-and-column-sorted matrix with a min-heap k-way merge or binary search on the value range.
LeetCode 373 (Medium) — find the k smallest pair sums from two sorted arrays in O(k log k) by treating the implicit pair-sum matrix as a sorted matrix and running a min-heap k-way merge.
LeetCode 630 (Hard) — a Google scheduling classic. Maximize courses you can finish before deadlines using a greedy max-heap that swaps out the longest course when budget overflows.
Find the minimum number of conference rooms required for all meetings by tracking room availability with a min-heap of end times — a classic interval scheduling problem asked at every major tech company and fundamental to resource allocation.
Find the minimum cost to connect all sticks by always merging the two shortest first — a direct application of the Huffman coding greedy principle, asked at Amazon and Facebook as a clean demonstration of optimal merge order.
Maximize capital after k IPO investments by unlocking affordable projects into a max-profit heap — a sophisticated two-heap greedy problem asked at Google, Amazon, and Facebook that models real-world portfolio optimization.
Check if a car can complete all trips without exceeding capacity by using a difference array or event-sweep — a clean interval problem with an O(1) space solution that appears at Amazon, Facebook, and Google for testing interval manipulation skills.
Reach the furthest building by greedily assigning ladders to the largest climbs and bricks to the rest — a nuanced greedy problem with a min-heap that appears at Amazon, Facebook, and Google and teaches optimal resource allocation under uncertainty.
LC 234 Palindrome Linked List is a popular interview problem at Facebook, Amazon, and Apple that combines three core techniques: fast/slow pointer midpoint finding, in-place list reversal, and two-pointer comparison. Master the O(1) space solution with Python and JavaScript code and a step-by-step dry run.
LC 160 Intersection of Two Linked Lists is a popular O(1) space interview question at Amazon, Facebook, and Microsoft. Learn the elegant two-pointer length-equalizer trick, the mathematical proof behind why it works, visual dry run, and Python/JavaScript solutions.
LC 19 Remove Nth Node From End of List is a classic one-pass interview problem at Amazon, Google, and Facebook that combines the dummy head sentinel with a two-pointer n-gap technique. Learn the optimal O(n) single-pass solution with Python and JavaScript, step-by-step dry run, and common interview traps.
LC 328 Odd Even Linked List is a medium interview problem at Facebook, Amazon, and LinkedIn that tests your ability to maintain two separate pointer chains simultaneously. Learn the O(1) space two-chain pattern with Python and JavaScript, a visual dry run, and interview tips.
LC 143 Reorder List is a composite interview problem at Facebook, Amazon, and Google that combines three core patterns: fast/slow midpoint finding, in-place second-half reversal, and interleaved merging. Master the O(1) space solution with Python and JavaScript, step-by-step visual trace, and interview approach.
LC 148 Sort List is a classic O(n log n) interview problem at Amazon, Google, and Facebook that applies merge sort to a linked list using fast/slow pointer splitting and recursive merging. Learn top-down merge sort with Python and JavaScript, a complete dry run, and the bottom-up O(1) space follow-up.
LC 138 Copy List with Random Pointer is a medium interview problem at Amazon, Microsoft, and Facebook that requires deep-copying a linked list where each node has a random pointer. Learn the O(n) space hash map approach and the clever O(1) space interleave technique with Python and JavaScript solutions and detailed dry run.
LC 287 Find the Duplicate Number is a brilliant medium interview problem at Amazon, Google, and Facebook where you find a duplicate in an n+1 integer array in O(1) space by treating the array as an implicit linked list and applying Floyd's cycle detection algorithm. Master the connection between arrays and linked lists with Python and JavaScript solutions and detailed proof.
LC 77 Combinations, LC 39 Combination Sum, and LC 40 Combination Sum II form a trilogy that every FAANG interviewer loves. Master the start-index pattern to enumerate selections without duplicates and the i+1 vs i reuse trick.
LC 51 N-Queens is the gold standard for testing backtracking, constraint propagation, and bit-mask elegance. Master row-by-row placement, three diagonal-tracking sets, and the bitmask trick that runs N=15 in milliseconds.
LC 37 Sudoku Solver is the most-asked constraint-satisfaction problem in tech interviews. Master row, column, and box bitsets, MRV heuristic ordering, and the cell-by-cell decision tree that solves any 9x9 grid in milliseconds.
LC 22 Generate Parentheses is the backtracking warm-up every FAANG interviewer reaches for. Master the open and close counter invariant, the Catalan number trail, and why a string-builder beats array joins for clean recursion.
LC 79 Word Search and LC 212 Word Search II ship in nearly every FAANG onsite. Master DFS with in-place visited marking, four-directional exploration, and the trie trick that turns multi-word search into a single traversal.
LC 17 Letter Combinations of a Phone Number is the cleanest cartesian-product backtracking template ever written. Master the digit-to-letter mapping, the per-position branching, and why the iterative BFS variant is asked at Amazon.
Simulate a baseball scoring game using a stack to handle score records, doubles, sum operations, and cancellations in O(n) time. A clean stack-simulation problem that tests your ability to model stateful operations with LIFO access.
Decode a run-length encoded string with nested brackets like 3[a2[bc]] using two stacks for counts and partial strings. A key FAANG problem testing nested structure parsing with stacks — the same pattern used in expression evaluators and compilers.
Simulate asteroid collisions where right-moving asteroids accumulate on the stack and left-moving ones destroy smaller ones on collision. A clean application of the collision-simulation stack pattern asked at Amazon and Bloomberg.
Find the minimum CPU intervals to execute all tasks with cooldown n using a greedy formula based on maximum frequency. A key FAANG problem testing greedy reasoning, frequency counting, and optionally heap-based simulation asked at Amazon, Google, and Facebook.
LeetCode 938 — Range Sum of BST, asked at Amazon, Facebook (Meta), Google and Apple. Use the BST property to prune entire out-of-range subtrees and run in O(h + k) time.
LC 124 Binary Tree Maximum Path Sum finds the highest-value path in a binary tree where the path can start and end at any node. The O(n) solution uses a post-order DFS that tracks the global max while returning only one branch to the parent — a critical FAANG interview problem at Amazon, Google, and Facebook.
LC 297 Serialize and Deserialize Binary Tree is a top FAANG hard problem asked at Facebook, Amazon, and Google. The DFS preorder approach with null markers gives a compact O(n) codec; BFS level-order is more intuitive. Both are valid interview answers.
LeetCode 510 (Medium) frequently asked at Microsoft and Facebook. Find the inorder successor of a BST node when each node has a parent pointer, in O(h) time and O(1) extra space without access to the root.
LeetCode 211 walkthrough — implement WordDictionary supporting add and search where the search query can contain a "." wildcard. The optimal solution combines a trie with DFS branching at every wildcard, a textbook FAANG interview pattern.
LC 15 asks for all unique triplets summing to zero. Sort the array, fix each element as the anchor, and use two pointers to scan for pairs — with careful three-level deduplication. A must-know FAANG pattern.
Find the smallest window in s containing all characters of t using have/need counters and a frequency map. The canonical hard sliding-window problem asked at every top tech company.
Find the longest substring containing at most 2 distinct characters using a variable sliding window backed by a character frequency map — a premium LinkedIn and Google problem with a clean generalization to k distinct.
Sort an array of 0s, 1s, and 2s in one pass with no extra space using the Dutch National Flag algorithm. Three pointers maintain sorted invariants for all three partitions simultaneously.
Check if a string can become a palindrome by deleting at most one character. Two pointers from both ends; on the first mismatch, try skipping left or skipping right and check if either remainder is a palindrome.
Solve LeetCode 42 Trapping Rain Water in O(n) time and O(1) space using the canonical two-pointer technique. Includes intuition, dry run, Python and JavaScript code, and follow-up variants.