Master swapping the kth node from start and end in a linked list using the two-pointer technique. A clean O(n) interview question asked at Amazon and Bloomberg that tests linked list traversal confidence and pointer discipline.
Master the write pointer pattern — the canonical technique for in-place array modification. Full walkthrough of LeetCode 26 with visual dry run, common mistakes, and the LC 80 generalization. Python and JavaScript solutions included.
LeetCode 344 is the canonical two-pointer problem — and it shows up at Meta, Microsoft, and Amazon as both a standalone question and as the foundation for palindrome checks, anagram detection, and rotate-array problems. Learn the in-place swap pattern deeply, trace through every edge case, and master the follow-ups that separate passing candidates from standout ones.
Master LeetCode 125 — Valid Palindrome with the O(1)-space two-pointer technique. Learn why every FAANG loop starts here, visualize the pointer walk on a classic example, avoid the four most common pitfalls, and unlock the palindrome follow-up chain: LC 680, LC 5, and LC 647.
Learn why 3Sum is a FAANG interview staple — how sorting enables two pointers, why deduplication trips up even strong candidates, a full visual dry run, and every common bug explained with Python and JavaScript solutions.
LeetCode 11 explained from scratch: why this is a greedy problem, the formal proof that you must always move the shorter pointer, a full step-by-step dry run, common traps, and clean Python + JavaScript solutions. Master the pointer-elimination pattern that appears throughout FAANG interviews.
LeetCode 189 looks trivial — until the interviewer asks for O(1) space. Learn why three distinct approaches exist, the mathematical reason triple-reverse works, every common pitfall (wrong k, direction confusion, off-by-one), a full visual dry run, and how this trick unlocks Rotate String, Rotate Image, and beyond.
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.
LeetCode 287 eliminates every naive approach through three hard constraints: no array modification, O(1) space, O(n) time. The solution — treating the array as an implicit linked list and running Floyd's tortoise-and-hare cycle detection — is one of the most elegant algorithm mappings in all of DSA. Full proof, visual dry run, Python and 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.
Master LeetCode 209 from first principles: understand why a variable-size shrinkable sliding window is the insight that cracks this problem in O(n), trace through every pointer movement on a real example, learn the three common interview mistakes, and be ready for the O(n log n) binary search follow-up that Amazon and Microsoft love to ask.
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.
Master LeetCode 795 using the elegant count(max <= R) - count(max <= L-1) subtraction trick — a powerful O(n) pattern that unlocks a whole family of subarray counting problems asked at Amazon, Google, and Meta.
LC 42 Trapping Rain Water is one of the most famous hard problems in FAANG interviews. The optimal two-pointer approach uses O(1) space. Knowing all three approaches and their trade-offs separates senior candidates from junior ones.
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.
Compare two typed strings after applying backspace characters using a stack simulation or O(1) space two-pointer from the right. Covers both approaches with full complexity analysis and FAANG interview tips.
String Compression (LC 443) is a deceptively careful two-pointer problem with strict in-place memory requirements. Master the read-write pointer pattern and you have the blueprint for in-place array transformations across many FAANG questions.
Master the two pointer and sliding window patterns that drive 15-20 percent of FAANG array and string interviews at Meta, Google, Amazon, Apple, and Netflix. This guide indexes 60 problems and the techniques behind every variant.
LeetCode 125 Valid Palindrome is the most common two pointer warm-up at Meta, Microsoft, and Amazon. Learn the inward-converging pointer technique that runs in O(n) time and O(1) space without building a cleaned copy of the string.
LeetCode 344 Reverse String is the simplest two pointer swap problem and a daily warm-up at Amazon, Apple, and Meta. Solve it in O(n) time and O(1) space using opposite-end pointers without allocating a new array.
LeetCode 977 Squares of a Sorted Array is a classic Google and Bloomberg two pointer question. Squaring negatives flips the sort order, so we merge from the outside in to produce a sorted output in O(n) time without re-sorting.
LeetCode 27 Remove Element introduces the fast and slow pointer pattern used in dozens of in-place array problems. Master the read and write index template here and LC 26, LC 283, and LC 80 become trivial.
LeetCode 26 Remove Duplicates from Sorted Array is the canonical fast and slow pointer deduplication problem. Microsoft, Meta, and Amazon use it to verify that candidates can compare against the previous kept element in O(n) time and O(1) space.
LeetCode 88 Merge Sorted Array is the classic three pointer in-place merge problem at Microsoft, Bloomberg, and Amazon. Walk both arrays from the end into the trailing empty slots to achieve O(m plus n) time with O(1) extra space.
LeetCode 392 Is Subsequence is a Google and Amazon greedy two pointer problem. Walk both strings forward, advance the source pointer only on matches, and answer in O(m plus n) time with O(1) space.
LeetCode 424 — a classic FAANG sliding window problem (Google, Microsoft, Amazon). Master the max-frequency invariant that powers the optimal O(n) solution.
LeetCode 567 — detect if any permutation of s1 appears as a substring of s2 using a fixed-size sliding window. Frequently asked at Google, Amazon, and Microsoft.
LeetCode 904 — find the longest contiguous subarray with at most two distinct values. A reskinned classic that appears in Google, Amazon, and Microsoft interviews.
LeetCode 1695 — find the maximum sum of a subarray with all unique values using a HashSet sliding window. A favorite at Google and Amazon for testing window invariants.
LC 881 asks for the minimum boats to rescue everyone given a weight limit and at-most-2-per-boat rule. Sort then greedily pair the heaviest with the lightest using two pointers — O(n log n) time, O(1) space.
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.
LeetCode 167 Two Sum II is asked at Amazon, Microsoft, Google, and Bloomberg. Solve it in O(n) time and O(1) space with the inward two-pointer technique on a sorted array.
LeetCode 713 Subarray Product Less Than K is asked at Google, Amazon, and Stripe. Count contiguous subarrays in O(n) using a multiplicative sliding window.
LeetCode 1423 Maximum Points You Can Obtain from Cards is asked at Google, Amazon, and Meta. Convert pick-from-ends into a fixed-size minimum-window problem in O(n).
LeetCode 1248 Count Number of Nice Subarrays is asked at Google and Amazon. Convert "exactly k odds" into atMost(k) minus atMost(k-1) for an O(n) solution.
LeetCode 930 Binary Subarrays With Sum is asked at Google, Amazon, and Meta. Count subarrays with exact sum in O(n) using atMost(goal) minus atMost(goal-1).
LeetCode 1838 Frequency of the Most Frequent Element is asked at Google and Amazon. Sort, then slide a window where total cost to lift everything to the rightmost value is at most k.
LeetCode 1658 Minimum Operations to Reduce X to Zero is asked at Amazon, Google, and Meta. Reframe to longest subarray summing to total minus x for an O(n) solution.
LeetCode 845 Longest Mountain in Array is asked at Google, Amazon, and Bloomberg. Find the longest strictly increasing-then-decreasing subarray in O(n) time, O(1) space.
LeetCode 992 Subarrays with K Different Integers is a Google, Amazon, and Meta hard. Solve in O(n) using the atMost(K) minus atMost(K-1) decomposition.
LeetCode 1234 Replace the Substring for Balanced String is asked at Google and Amazon. Find the minimum window to replace in O(n) using a shrinkable sliding window over QWER frequencies.
LC 1888 asks for the minimum flips to make a binary string alternating after any rotations. Double the string and slide a fixed window of size n against both target patterns — the canonical circular sliding window trick.
LC 1456 asks for the maximum vowels in any substring of length k. A canonical fixed-size sliding window — add the new right character, subtract the departing left character, track the running max. O(n) time, O(1) space.
LC 1151 asks for minimum swaps to group all 1s in a circular binary array. Count total 1s to set the window size, then maximize 1s inside any window position using modulo indexing. O(n) time, O(1) space.
LC 2516 asks for the minimum minutes to collect at least k of each character from a string's ends. Flip it: find the longest middle window you can skip so the outside has enough of each character. O(n) time, O(1) space.
LC 1052 maximizes satisfied customers by finding the optimal k-minute grumpiness suppression window. Decompose into a fixed base plus a variable bonus — then find the max-bonus window with a standard fixed-size sliding window. O(n) time, O(1) space.
LC 1984 asks for the minimum max-minus-min over any k chosen scores. The optimal k scores are always contiguous in sorted order — sort once then scan windows of size k in O(n log n) time, O(1) space.
LC 1208 asks for the longest substring of s transformable to t within total cost maxCost, where each character costs the absolute ASCII difference. Classic variable sliding window: expand right, shrink left while cost exceeds budget. O(n) time, O(1) space.
LC 1358 counts substrings containing at least one a, b, and c. Track the last-seen index of each character — the count of valid substrings ending at position i is min(last_seen) + 1. O(n) time, O(1) space.
LC 974 counts subarrays whose sum is divisible by k using prefix sums modulo k and a frequency map of remainders. O(n) time, O(k) space. The standard FAANG pattern for all modular subarray problems.
LeetCode 487 asked at Microsoft, Meta, and Amazon. Track the last zero index instead of a counter to handle the streaming follow-up in O(n) time and O(1) space.
LeetCode 727 asked at Google and Amazon. A forward scan finds a valid right boundary, then a backward scan tightens the left boundary in O(|s|*|t|) time.
LeetCode 30 asked at Google, Amazon, and Meta. Run a word-aligned sliding window for each of the wlen possible offsets to find every concatenation start in O(n*wlen) time.
LC 2260 asks for the shortest consecutive sequence of cards containing a matching pair. Track the last-seen index of each card value — update the minimum window each time a duplicate is encountered. O(n) time, O(n) space.
Count subarrays where score = sum × length is less than k using a shrinkable sliding window with a running sum. Counting all valid subarrays ending at each right pointer is the key trick that avoids an inner loop.
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 maximum in every sliding window of size k in O(n) using a monotonic decreasing deque of indices — the classic hard problem that separates senior engineers from the rest.
Find the shortest subarray whose sum is at least k, even with negative numbers, using a monotone increasing deque on prefix sums — the canonical hard problem where a simple sliding window fails.
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.
Find the longest contiguous subarray of 1s after deleting exactly one element. Reframe as "longest window with at most one zero," then subtract 1 for the mandatory deletion. A clean shrinkable window problem.
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.
Check whether an integer array can be split into three contiguous parts with equal sum. LeetCode 1013 in O(n) using a greedy single-pass counter, with full Python and JavaScript code.
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.
Complete master cheatsheet of every two-pointer and sliding window pattern used in coding interviews. Includes template code, problem index, decision tree, and MAANG priority list.