LeetCode 975: Odd Even Jump
A clear explanation of counting good starting indices using next-jump preprocessing and dynamic programming.
379 notes
A clear explanation of counting good starting indices using next-jump preprocessing and dynamic programming.
A clear explanation of counting subarrays whose sum is divisible by k using prefix sums and remainder frequencies.
A clear explanation of returning the k closest points to the origin using squared distance and sorting.
A clear explanation of sorting an array using prefix reversals by repeatedly placing the largest remaining value.
A clear explanation of implementing a spellchecker with exact, case-insensitive, and vowel-error matching.
A clear explanation of finding the maximum width ramp using a monotonic decreasing stack.
A clear explanation of finding the element repeated N times using a hash set.
A clear explanation of simulating prison cell transitions efficiently using cycle detection.
A clear explanation of solving Tallest Billboard using dynamic programming over height differences.
A clear explanation of deleting the minimum number of columns so rows become lexicographically sorted.
A clear explanation of checking whether an array can be reordered into pairs where one number is double the other.
A clear explanation of solving Largest Component Size by Common Factor using prime factorization and union find.
A clear explanation of the Rectangle Area II problem using sweep line and merged active y-intervals.
A clear explanation of the Maximize Distance to Closest Person problem using gaps between occupied seats.
A clear explanation of the Shifting Letters problem using suffix sums and modulo arithmetic.
A clear explanation of the Hand of Straights problem using sorting, frequency counting, and greedy grouping.
A clear explanation of the Longest Mountain in Array problem using peak detection and two-pointer expansion.
A clear explanation of the Guess the Word interactive problem using candidate filtering and minimax-style guessing.
A clear explanation of the Magic Squares In Grid problem using fixed-size subgrid validation.
A clear explanation of the Image Overlap problem using translation vectors and frequency counting.
A clear explanation of the Find And Replace in String problem using simultaneous replacement, source matching, and a replacement map.
A clear explanation of the Flipping an Image problem using row reversal, bit inversion, and an in-place two-pointer method.
A clear explanation of the Making A Large Island problem using connected component labeling and island size lookup.
A clear explanation of the Most Profit Assigning Work problem using sorting, greedy choice, and two pointers.
A clear explanation of counting index triplets with duplicate values using frequency counts and combinatorics.
A clear explanation of placing even numbers at even indices and odd numbers at odd indices using two pointers.
A clear explanation of finding the maximum circular subarray sum using Kadane's algorithm.
A clear explanation of finding universal words by merging character frequency requirements from words2.
A clear explanation of finding the smallest left partition using prefix maximums and suffix minimums.
A clear explanation of checking whether card counts share a common group size using the greatest common divisor.
A clear explanation of sorting an array without built-in sorting using merge sort.
A clear explanation of Online Election using preprocessing and binary search over vote times.
A clear explanation of minimizing the array range after adding either +k or -k to every element.
A clear explanation of minimizing an array score after each value can move by at most k.
A clear explanation of summing subarray minimums using a monotonic stack and contribution counting.
A clear explanation of sorting an array by parity using a two-pointer partition method.
A clear explanation of Fruit Into Baskets using a sliding window with at most two distinct fruit types.
A clear explanation of designing an iterator over a run-length encoded sequence without expanding it.
A clear explanation of counting distinct bitwise OR results from all non-empty subarrays using rolling sets.
A clear explanation of checking whether an array is monotonic using one pass and direction flags.
A clear explanation of counting special-equivalent string groups by building canonical signatures from even and odd positions.
A clear explanation of computing the exposed surface area of stacked cubes by adding tower area and subtracting shared faces.
A clear explanation of summing subsequence widths by sorting and counting each element as a maximum and minimum.
A clear explanation of finding words that match a pattern using bijective character mapping.
A clear explanation of reconstructing a binary tree from preorder and postorder traversals using recursion and index ranges.
A clear explanation of finding one candy box swap that makes Alice and Bob have equal total candies.
A clear explanation of generating grid coordinates in an outward clockwise spiral using simulation.
A clear explanation of minimizing rescue boats using sorting, greedy choice, and two pointers.
A clear explanation of counting profitable crime schemes using 0/1 knapsack dynamic programming with members and profit states.
A clear explanation of the Stone Game problem using game theory and interval dynamic programming.
A clear explanation of Maximum Distance in Arrays using sorted endpoints and a greedy scan.
A clear explanation of Design Circular Queue using a fixed array, a front pointer, and a size counter.
A clear explanation of Task Scheduler using frequency counting and the greedy block formula.
A clear explanation of grouping strings by their shifting sequence using normalized hash keys.
A clear explanation of generating all strobogrammatic numbers of length n using recursion from the inside out.
A clear explanation of the Shortest Word Distance III problem, including the special case where both target words are the same.
A clear explanation of the Shortest Word Distance II problem using preprocessing and two pointers.
A clear explanation of the Shortest Word Distance problem using one pass and the latest seen indices of both words.
A clear explanation of merging consecutive stone piles with minimum cost using interval dynamic programming.
A clear explanation of counting how many pawns a rook can capture by scanning four directions on a chessboard.
A clear explanation of identifying the town judge using trust indegree and outdegree counts.
A clear explanation of counting unique permutations where every adjacent pair sums to a perfect square using backtracking.
A clear explanation of making all bits equal to 1 using greedy left-to-right flips and a sliding window flip parity.
A clear explanation of finding the minimum time for all oranges to rot using multi-source BFS.
A clear explanation of counting subarrays with exactly k distinct integers using the at-most-k sliding window trick.
A clear explanation of checking equality and inequality constraints using union-find.
A clear explanation of adding an integer to an array-form number using digit-by-digit simulation.
A clear explanation of finding intersections between two sorted disjoint interval lists using two pointers.
A clear explanation of maintaining the sum of even numbers after each array update.
A clear explanation of finding the cheapest way to cover all travel days using dynamic programming.
A clear explanation of counting ordered triples whose bitwise AND is zero using pairwise AND counts.
A clear explanation of counting all paths from start to end that visit every non-obstacle square exactly once using backtracking.
A clear explanation of finding the longest subarray whose adjacent comparisons alternate between greater-than and less-than.
A clear explanation of sorting squared values from a sorted array using two pointers.
A clear explanation of finding the largest valid triangle perimeter using sorting and a greedy scan.
A clear explanation of finding the minimum banana-eating speed using binary search on the answer.
A clear explanation of simulating robot movement on an infinite grid using direction vectors and obstacle lookup.
A clear explanation of finding the longest Fibonacci-like subsequence using dynamic programming and value-to-index lookup.
A clear explanation of minimizing refueling stops using a greedy max heap over reachable stations.
A clear explanation of maximizing the advantage of one array over another using sorting, greedy matching, and two pointers.
A clear explanation of transposing a matrix by swapping row and column indices.
A clear explanation of finding the shortest non-empty subarray with sum at least k using prefix sums and a monotonic deque.
A clear explanation of Lemonade Change using greedy simulation and bill counting.
A clear explanation of hiring exactly k workers with minimum total cost using wage-to-quality ratios, sorting, and a max heap.
A clear explanation of counting car fleets by sorting cars by position and tracking arrival times.
A clear explanation of finding the peak index in a mountain array using binary search.
A clear explanation of solving Reveal Cards In Increasing Order using sorting and queue simulation over indices.
A clear explanation of solving Largest Time for Given Digits by checking all permutations of four digits.
A clear explanation of solving Bag of Tokens using sorting, greedy choices, and two pointers.
A clear explanation of solving Validate Stack Sequences by simulating stack push and pop operations.
A clear explanation of solving Minimum Increment to Make Array Unique by sorting and greedily assigning the next available value.
A clear explanation of solving Delete Columns to Make Sorted by checking each column independently.
A clear explanation of solving DI String Match using a greedy two-pointer construction.
A clear explanation of solving Valid Mountain Array by walking up the increasing slope and then down the decreasing slope.
A clear explanation of solving Minimum Area Rectangle using diagonal point pairs and constant-time point lookup.
A clear explanation of solving Beautiful Array using divide and conquer with odd and even transformations.
A clear explanation of solving Minimum Falling Path Sum using dynamic programming over matrix rows.
A clear explanation of solving Binary Subarrays With Sum using prefix sums and a frequency map.
A clear explanation of solving Three Equal Parts by counting ones, locating the three binary patterns, and comparing them in one pass.
A counting solution for computing how many directed friend requests are allowed by age rules.
A dynamic programming solution for counting binary trees where every non-leaf node is the product of its children.
A hash set solution for finding the smallest number that can be hidden from all front-facing cards.
A two-pass solution for computing the shortest distance from each index to the nearest occurrence of a target character.
A hash set and linked list traversal solution for counting consecutive components whose values appear in nums.
A dynamic programming and prefix sum solution for partitioning an array into adjacent groups with maximum total average.
A geometry solution for finding the largest triangle area by checking every triplet of points with the cross product formula.
A greedy solution for increasing building heights as much as possible while preserving every skyline view.
A simple simulation solution for counting how many 100-pixel lines are needed to write a string.
A set-based solution for counting how many different Morse code transformations appear among a list of words.
A dynamic programming solution for finding the minimum number of same-index swaps needed to make two arrays strictly increasing.
A clear explanation of finding the smallest rotation with maximum score using a difference array.
A clear explanation of counting contiguous subarrays whose maximum value lies inside a given inclusive range.
A clear explanation of validating whether a Tic-Tac-Toe board can occur in a legal game.
A clear explanation of finding the kth smallest fraction from a sorted array using a min-heap.
A clear explanation of finding the minimum possible number of rabbits using counting and greedy grouping.
A clear explanation of checking whether every global inversion is also a local inversion using distance constraints.
A clear explanation of minimizing the largest adjacent gas-station distance using binary search on the answer.
A clear explanation of splitting a permutation into the maximum number of chunks using prefix maximums.
A clear explanation of splitting an array into the maximum number of chunks so sorting each chunk gives the fully sorted array.
A clear explanation of checking whether every top-left to bottom-right diagonal in a matrix has the same value.
A clear explanation of minimizing swaps so every couple sits together using greedy position tracking.
A clear explanation of mapping each element in one array to a matching index in its anagram using a hash map.
A clear explanation of finding common free time by merging all employee busy intervals and returning the gaps.
A clear explanation of simulating water droplets over an elevation map by checking left first, then right.
A clear explanation of finding the leftmost pivot index using prefix sums and a running left sum.
A clear explanation of restoring a Candy Crush board to a stable state using repeated marking, crushing, and gravity simulation.
A clear explanation of removing line comments and block comments from source code using a state machine.
A clear explanation of merging accounts that share emails using union find and sorted email groups.
A clear explanation of finding the kth smallest pair distance using sorting, binary search on the answer, and a two-pointer count.
A clear explanation of finding the longest common contiguous subarray using dynamic programming.
A clear explanation of determining whether the last character must be a one-bit character using greedy parsing.
A clear explanation of maximizing stock trading profit with unlimited transactions and a fixed transaction fee using dynamic programming.
A clear explanation of counting contiguous subarrays whose product is less than k using a sliding window.
A clear explanation of designing a hash map without using built-in hash table libraries.
A clear explanation of designing a hash set without using built-in hash table libraries.
A clear explanation of searching for a target in a sorted array using binary search.
A clear explanation of searching in a sorted array when the array length is hidden behind an ArrayReader interface.
Count axis-aligned rectangles whose four corners are 1 using column-pair frequency counting.
Simulate virus containment by repeatedly quarantining the most dangerous infected region and spreading the remaining regions.
Find whether the maximum element is at least twice every other element using a single linear scan.
Find the minimum cost to reach the top of the staircase using dynamic programming.
Use binary search to find the smallest character strictly greater than the target with wraparound handling.
Maximize cherries collected on a round trip by converting the problem into two simultaneous forward paths and solving with dynamic programming.
Transform the problem into House Robber dynamic programming by grouping equal values into total points.
Find how many days each temperature must wait for a warmer future day using a monotonic stack.
Check sentence similarity with transitive word relationships using union-find.
Simulate asteroid collisions using a stack that keeps the surviving asteroids in order.
Check whether two word arrays are sentence-similar using a hash set of symmetric similar word pairs.
Recolor the connected component containing the starting pixel using depth-first search.
Allow double bookings but reject triple bookings using overlap interval tracking.
Implement a calendar that accepts a booking only when it does not overlap with any existing booking.
Decide whether an array can be divided into k non-empty subsets with equal sums using backtracking and pruning.
Find the shortest contiguous subarray with the same degree as the whole array using frequency counts and first occurrence indices.
Find the largest connected island area in a binary grid using depth-first search.
Count unique island shapes in a binary grid using DFS and relative coordinates.
Find three non-overlapping subarrays of length k with maximum total sum and return the lexicographically smallest starting indices.
Find the earliest day when two turned-on bulbs have exactly k turned-off bulbs between them using a sliding window over bloom days.
Simulate a baseball scoring system using a stack to process operations and compute the final score.
Determine whether four numbers can be combined with arithmetic operations and parentheses to produce 24.
A clear explanation of cutting trees in increasing height order using repeated BFS on a grid.
A clear explanation of finding the longest strictly increasing contiguous subarray using a single scan.
A clear explanation of counting how many longest strictly increasing subsequences exist using dynamic programming.
A clear explanation of constructing an array with exactly k distinct adjacent differences using a greedy pattern.
A clear explanation of checking whether an array can become non-decreasing by modifying at most one element.
A clear explanation of averaging neighboring pixels in a matrix using direct simulation.
A clear explanation of deciding whether a sorted array can be split into consecutive subsequences of length at least three.
A clear explanation of finding the k closest elements to a target using binary search and a sliding window.
A clear explanation of finding the minimum-cost path with bounded jumps, blocked cells, and lexicographic tie-breaking.
A counting and math solution for finding the duplicated number and the missing number in a corrupted set.
A binary search solution for finding the maximum average of any contiguous subarray with length at least k.
A sliding window solution for finding the maximum average among all contiguous subarrays of fixed length k.
An array-based circular buffer solution for implementing a fixed-size double-ended queue.
A design solution for storing timestamped logs and retrieving IDs by inclusive time range at a chosen granularity.
A heap-based solution for finding the smallest range that contains at least one number from each sorted list.
A greedy heap solution for taking the maximum number of courses before their deadlines.
A clear explanation of finding the largest product of three numbers using sorting or constant-space tracking.
A two-pointer guide for counting triplets that can form valid triangles after sorting the side lengths.
A hash map guide for grouping file paths by identical file content and returning only duplicate groups.
A greedy guide for determining whether a given number of flowers can be planted without violating the no-adjacent-flowers rule.
A guide to implementing a lazy iterator over a run-length encoded string without fully decompressing it.
A clear explanation of searching a row-sorted and column-sorted matrix using the top-right corner elimination method.
A clear explanation of finding the maximum value in every sliding window using a monotonic deque.
A clear explanation of computing each product except self using prefix and suffix products without division.
A clear explanation of finding all elements that appear more than n/3 times using the extended Boyer-Moore voting algorithm.
A clear explanation of summarizing a sorted unique integer array into compact consecutive ranges.
A clear explanation of Group Anagrams using a hash map keyed by each word's sorted character signature.
A clear explanation of Rotate Image using in-place matrix transpose and row reversal.
A clear explanation of Permutations II using sorting, depth-first search, and duplicate-skipping backtracking.
A clear explanation of Permutations using depth-first search and backtracking.
A clear explanation of Jump Game II using a greedy range expansion approach to find the minimum number of jumps.
A clear explanation of the Trapping Rain Water problem using left and right boundaries, then an optimized two-pointer solution.
A clear explanation of the First Missing Positive problem using in-place index placement to achieve O(n) time and O(1) extra space.
A clear hash map solution for finding common strings with the smallest index sum.
A clear math solution for counting the maximum values after repeated top-left matrix increment operations.
A clear hash map solution for finding the longest subsequence whose maximum and minimum differ by exactly one.
A clear convex hull solution for returning all trees that lie on the fence boundary.
A clear linear-time solution for finding the shortest subarray that must be sorted to make the whole array sorted.
A clear explanation of Distribute Candies using a set to count candy types and a simple limit argument.
A clear explanation of Reshape the Matrix using index mapping from the original matrix to the reshaped matrix.
A clear explanation of Array Nesting using cycle detection over a permutation.
A clear explanation of Longest Line of Consecutive One in Matrix using dynamic programming over four directions.
A clear explanation of Array Partition using sorting and adjacent pairing to maximize the sum of pair minimums.
A clear explanation of Subarray Sum Equals K using prefix sums and a hash map to count matching subarrays in linear time.
A clear explanation of Brick Wall using prefix sums and a hash map to find the best vertical cut position.
A clear explanation of Optimal Division using the structure of division expressions to build the maximum-value expression.
A clear explanation of splitting an array into four equal-sum parts using prefix sums and set-based search.
A clear explanation of computing the distance to the nearest zero in a binary matrix using multi-source BFS.
A clear explanation of finding the only non-duplicate element in a sorted array using binary search.
A clear explanation of finding the minimum difference between 24-hour clock times using minute conversion and sorting.
A clear explanation of counting black lonely pixels using row counts, column counts, and duplicate row patterns.
A clear explanation of counting unique pairs whose absolute difference is k using frequency counting.
A clear explanation of counting black pixels that are alone in both their row and column.
A clear explanation of updating a Minesweeper board using DFS flood fill and adjacent mine counting.
A clear explanation of weighted random sampling using prefix sums and binary search.
A clear explanation of finding the longest contiguous subarray with equal numbers of 0 and 1 using prefix sums and a hash map.
A clear explanation of detecting a subarray whose sum is a multiple of k using prefix sums and modular arithmetic.
A clear explanation of finding the longest uncommon subsequence among many strings using subsequence checks.
A clear explanation of counting coin-change combinations using dynamic programming.
A clear explanation of balancing dresses across washing machines using greedy prefix flow.
A clear explanation of assigning athlete ranks from scores using sorting while preserving original indices.
A clear explanation of finding the next greater element in a circular array using a monotonic stack.
A clear explanation of filtering words that can be typed using only one row of an American keyboard.
A clear explanation of returning matrix elements in diagonal zigzag order by grouping cells with the same row plus column index.
A clear explanation of finding the next greater element using a monotonic decreasing stack and hash map.
A clear explanation of calculating total poisoned duration by merging overlapping attack intervals.
A clear explanation of counting sign assignments that reach a target using recursion first, then subset-sum dynamic programming.
A clear explanation of counting pairs where nums[i] is greater than twice nums[j] using merge sort.
A clear explanation of generating all distinct non-decreasing subsequences using DFS, backtracking, and per-level duplicate control.
A clear explanation of finding the longest run of 1s after flipping at most one 0 using a sliding window.
A clear explanation of predicting whether Player 1 can win using minimax dynamic programming over score difference.
A clear explanation of finding the longest streak of 1s in a binary array with a single pass.
A clear explanation of constructing the lexicographically smallest permutation that matches an I and D pattern.
A clear explanation of maintaining the median of each fixed-size window using two heaps and lazy deletion.
A clear explanation of computing the total Hamming distance across all pairs by counting different bits column by column.
A clear explanation of finding the minimum heater radius by sorting positions and matching each house to its nearest heater.
A clear explanation of solving the largest subset problem as a two-dimensional 0/1 knapsack over zero and one counts.
A clear explanation of deciding whether matchsticks can form a square using backtracking, sorting, and pruning.
A clear explanation of checking whether ordered points form a convex polygon using cross products.
A clear explanation of minimizing debt-settlement transactions using net balances, backtracking, and memoization-style pruning.
A clear explanation of counting the perimeter of an island in a grid by adding land-cell edges and subtracting shared edges.
A clear explanation of why the median minimizes the number of moves needed to make all array elements equal.
A clear explanation of detecting a valid cycle in a circular array using fast and slow pointers.
A clear explanation of detecting a 132 pattern using reverse traversal and a monotonic stack.
A clear explanation of the greedy two-pointer solution for maximizing the number of content children.
A clear explanation of counting zero-sum tuples across four arrays using pair sums and a hash map.
A clear explanation of the math behind making all array elements equal by incrementing n - 1 elements at a time.
A clear explanation of the greedy interval solution for finding the minimum number of arrows needed to burst all balloons.
Find all missing numbers from 1 to n in O(n) time using in-place index marking.
Count ordered boomerang tuples by fixing each point as the center and grouping other points by squared distance.
Count arithmetic subsequences of length at least three using dynamic programming with one hash map per ending index.
Compress a character array in-place using two pointers and grouped character counting.
Find all duplicated numbers in an array in O(n) time and O(1) extra space using index marking.
Find, for each interval, the interval with the smallest start point greater than or equal to its end point using sorting and binary search.
Remove the minimum number of intervals so the remaining intervals do not overlap, using greedy sorting by end time.
A clear explanation of building all word squares using backtracking with prefix pruning.
A clear explanation of checking whether rows and columns read the same using direct index comparison.
A clear explanation of finding the maximum XOR of two numbers using greedy bit prefixes.
A clear explanation of counting battleships in a board using one-pass observation without modifying the grid.
A clear explanation of deciding whether an array can be split into two equal-sum subsets using 0/1 knapsack dynamic programming.
A clear explanation of finding the third distinct maximum number using one pass and constant space.
A clear explanation of counting arithmetic subarrays using dynamic programming and consecutive differences.
A clear explanation of minimizing the largest subarray sum using binary search on the answer and greedy validation.
A clear explanation of reconstructing a queue using greedy sorting and indexed insertion.
A clear explanation of picking a uniformly random index for a target value using reservoir sampling, with an alternative hash map approach.
A clear explanation of maximizing the rotation function using a recurrence instead of simulating every rotation.
A clear explanation of validating a byte sequence as UTF-8 using bit masks and a continuation-byte counter.
A clear explanation of checking whether many small axis-aligned rectangles form one exact rectangular cover using area and corner parity.
A clear explanation of shuffling an array uniformly using the Fisher-Yates algorithm while supporting reset.
A clear explanation of designing a randomized multiset with average O(1) insert, remove, and getRandom operations.
A clear explanation of designing a randomized set with average O(1) insert, remove, and getRandom operations.
A clear explanation of finding the kth smallest value in a row-sorted and column-sorted matrix using binary search on values.
A clear explanation of Combination Sum IV using dynamic programming to count ordered combinations that sum to a target.
A clear explanation of the Wiggle Subsequence problem using dynamic programming intuition and an optimized greedy solution.
A clear explanation of finding the k smallest pair sums from two sorted arrays using a min heap and best-first search.
A clear explanation of applying many range updates efficiently using a difference array and prefix sums.
A clear explanation of finding the largest subset where every pair is divisible using sorting, dynamic programming, and parent reconstruction.
A clear explanation of reducing a 2D rectangle problem to a 1D prefix-sum problem with binary search.
A clear explanation of sorting values after applying a quadratic function using two pointers.
A clear explanation of Intersection of Two Arrays II using frequency counting.
A clear explanation of Intersection of Two Arrays using hash sets for uniqueness and fast lookup.
A clear explanation of Design Tic-Tac-Toe using row, column, and diagonal counters for constant-time winner checks.
A clear explanation of Top K Frequent Elements using frequency counting and bucket sort.
A clear explanation of Palindrome Pairs using reversed-word lookup and palindrome split checks.
A clear explanation of Self Crossing using constant-space checks for the only possible crossing patterns.
A clear explanation of Increasing Triplet Subsequence using greedy tracking of two minimum values.
A clear explanation of Patching Array using a greedy smallest-missing-sum invariant.
A clear explanation of Count of Range Sum using prefix sums and merge sort counting.
A clear explanation of Maximum Size Subarray Sum Equals k using prefix sums and earliest-index hashing.
A clear explanation of Wiggle Sort II using sorting, median splitting, and virtual indexing.
A clear explanation of Coin Change using dynamic programming for minimum coin count.
A clear explanation of Create Maximum Number using monotonic stacks for subsequences and greedy merging.
A clear explanation of Maximum Product of Word Lengths using bit masks to test disjoint character sets efficiently.
A clear explanation of Count of Smaller Numbers After Self using coordinate compression and a Fenwick Tree.
A clear explanation of Burst Balloons using interval dynamic programming and the last-burst idea.
A clear explanation of Best Time to Buy and Sell Stock with Cooldown using dynamic programming states.
A clear explanation of Range Sum Query - Mutable using a Fenwick Tree for efficient updates and range sums.
A clear explanation of Range Sum Query - Immutable using prefix sums for constant-time range queries.
A clear explanation of Smallest Rectangle Enclosing Black Pixels using binary search on rows and columns.
A dynamic programming and patience sorting solution for finding the longest strictly increasing subsequence in an array.
A Floyd cycle detection solution for finding the repeated number without modifying the array and using constant extra space.
A two-pointer in-place solution for moving all zeroes to the end while preserving the relative order of non-zero elements.
A queue-based iterator design for returning elements from two vectors in alternating order, with a clean extension to k vectors.
A greedy in-place solution for rearranging an array into a non-strict wiggle pattern.
A clear explanation of the H-Index II problem using binary search on a sorted citations array.
A clear explanation of the H-Index problem using sorting, then an optimized counting approach.
A clear explanation of the Missing Number problem using sum formula and XOR.
A clear explanation of the Paint House II problem using optimized dynamic programming with minimum and second minimum tracking.
A clear explanation of the 3Sum Smaller problem using sorting and the two-pointer technique.
A clear explanation of the Paint House problem using dynamic programming with constant space.
A clear explanation of the Flatten 2D Vector problem using row and column pointers to implement an iterator.
A clear explanation of checking nearby indices with nearby values using a sliding window and bucket hashing.
A clear explanation of detecting whether equal values appear within distance k using a hash map or sliding window set.
A clear explanation of detecting duplicates in an array using a hash set and sorting.
A clear explanation of finding k distinct numbers from 1 to 9 that sum to n using backtracking.
A clear explanation of finding the kth largest element using sorting, a min-heap, and Quickselect.
A clear explanation of maximizing robbed money from circularly arranged houses using dynamic programming.
A clear explanation of finding the shortest contiguous subarray whose sum is at least target using a sliding window.
A detailed guide to solving Subsets II with sorting, backtracking, and duplicate skipping.
A detailed guide to solving Merge Sorted Array in-place by merging from the back with three pointers.
A detailed guide to solving Maximal Rectangle by converting each matrix row into a histogram and applying a monotonic stack.
A detailed guide to solving Largest Rectangle in Histogram with a monotonic increasing stack.
A detailed guide to solving Search in Rotated Sorted Array II with modified binary search and duplicate handling.
A detailed guide to solving Remove Duplicates from Sorted Array II with an in-place two-pointer method.
A detailed guide to solving Word Search with depth-first search and backtracking on a grid.
A detailed guide to solving Subsets with backtracking and the include-or-skip recursion idea.
A clear explanation of maximizing robbery profit without robbing adjacent houses using dynamic programming.
A clear explanation of rotating an array to the right by k steps using in-place reversal.
A clear explanation of maximizing stock trading profit with at most k transactions using dynamic programming.
A clear explanation of reversing the order of words in a character array in-place using two reversals.
A clear explanation of arranging non-negative integers to form the largest possible concatenated number using a custom sort order.
A clear explanation of finding the element that appears more than half the time using Boyer-Moore voting.
A clear explanation of finding two numbers in a sorted array using two pointers and constant extra space.
A clear explanation of finding the maximum adjacent gap in sorted order using buckets and the pigeonhole principle.
A clear explanation of finding all missing ranges inside an inclusive interval by scanning sorted unique numbers.
A clear explanation of finding any peak element using binary search on the slope of the array.
A clear explanation of implementing read with read4 when read may be called multiple times.
A clear explanation of implementing read using the given read4 API and copying only the needed characters.
A clear explanation of finding the minimum element in a rotated sorted array that may contain duplicates.
A clear explanation of finding the minimum element in a rotated sorted array using binary search.
A detailed explanation of tracking both maximum and minimum products while scanning the array.
Find the number that appears once when every other number appears three times using bit counting or finite-state bit manipulation.
Find the only number that appears once using the XOR operator, while every other number appears exactly twice.
Compute the minimum candies needed using two greedy passes, one from the left and one from the right.
Find the unique starting gas station index using a greedy scan with total fuel balance and current tank balance.
Capture surrounded O regions by marking border-connected O cells first, then flipping the remaining O cells.
Find the longest run of consecutive integers in an unsorted array using a hash set and sequence-start detection.
A clear explanation of maximizing stock profit with at most two transactions using dynamic programming.
A clear explanation of maximizing stock profit with unlimited transactions using a greedy single-pass method.
A clear explanation of finding the maximum profit from one stock transaction using a single pass.
A clear explanation of finding the minimum path sum in a triangle using bottom-up dynamic programming.
A clear explanation of generating a single row of Pascal's Triangle using in-place dynamic programming.
A clear explanation of generating Pascal's Triangle row by row using dynamic programming.
A clear guide to sorting an array of 0s, 1s, and 2s in place using the Dutch National Flag algorithm.
A clear guide to searching a sorted 2D matrix using binary search over a virtual one-dimensional array.
A clear guide to setting matrix rows and columns to zero in place using the first row and first column as markers.
A clear guide to formatting text with greedy line packing and even space distribution.
A clear guide to adding one to a large integer represented as an array of digits.
A clear guide to generating an n x n matrix filled from 1 to n squared in spiral order.
A clear guide to solving Insert Interval with one linear scan over sorted, non-overlapping intervals.
A clear guide to solving Merge Intervals by sorting intervals and merging them in one pass.
A clear guide to solving Jump Game with greedy reachability.
A clear guide to reading a matrix in spiral order using shrinking boundaries.
A clear guide to solving Maximum Subarray with brute force first, then Kadane's dynamic programming algorithm.
A clear guide to solving N-Queens with backtracking, row-by-row placement, and constant-time conflict checks.
A clear explanation of finding unique combinations that sum to a target when each array element may be used at most once.
A clear explanation of finding all unique combinations that sum to a target using backtracking.
A clear explanation of checking whether a partially filled Sudoku board is valid using hash sets.
A clear explanation of finding the index of a target, or where it should be inserted, using binary search.
A clear explanation of finding the first and last index of a target in a sorted array using two binary searches.
A clear explanation of searching a rotated sorted array in logarithmic time using modified binary search.
A clear explanation of finding the next lexicographically greater permutation in place using a right-to-left scan.
A clear explanation of removing all occurrences of a value from an array in place using a write pointer.
A clear explanation of removing duplicates from a sorted array in place using two pointers.
A detailed explanation of finding all unique quadruplets that sum to a target using sorting and two pointers.
A detailed explanation of finding the sum of three integers closest to a target using sorting and two pointers.
A detailed explanation of finding all unique triplets that sum to zero using sorting and two pointers.
A detailed explanation of finding the maximum water container area using two pointers.
A detailed explanation of finding the median of two sorted arrays using binary search over partitions.
A clear explanation of the Two Sum problem using brute force first, then an optimized hash map solution.