LeetCode 975: Odd Even Jump
A clear explanation of counting good starting indices using next-jump preprocessing and dynamic programming.
148 notes
A clear explanation of counting good starting indices using next-jump preprocessing and dynamic programming.
A clear explanation of expressing a target using the fewest operators with repeated uses of x.
A clear explanation of deleting the minimum number of columns so every remaining row is individually sorted.
A clear explanation of solving Tallest Billboard using dynamic programming over height differences.
A clear explanation of the Shortest Path Visiting All Nodes problem using multi-source BFS and bitmask state compression.
A clear explanation of the Push Dominoes problem using force propagation and a two-pass scan.
A clear explanation of the New 21 Game problem using probability dynamic programming and a sliding window sum.
A clear explanation of the Sum of Distances in Tree problem using tree DP, subtree sizes, and rerooting.
A clear explanation of Count Unique Characters of All Substrings using contribution counting with previous and next occurrences.
A clear explanation of counting valid music playlists using dynamic programming over playlist length and unique songs used.
A clear explanation of finding the maximum circular subarray sum using Kadane's algorithm.
A clear explanation of counting valid DI permutations using dynamic programming and prefix sums.
A clear explanation of counting distinct bitwise OR results from all non-empty subarrays using rolling sets.
A clear explanation of generating all full binary trees with n nodes using recursion and memoization.
A clear explanation of finding the minimum worst-case number of moves using dynamic programming over eggs and moves.
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 merging consecutive stone piles with minimum cost using interval dynamic programming.
A clear explanation of finding the cheapest way to cover all travel days using dynamic programming.
A clear explanation of finding the longest subarray whose adjacent comparisons alternate between greater-than and less-than.
A clear explanation of finding the longest Fibonacci-like subsequence using dynamic programming and value-to-index lookup.
A clear explanation of solving Find the Shortest Superstring using pairwise overlaps and bitmask dynamic programming.
A clear explanation of solving Distinct Subsequences II using dynamic programming and last occurrence tracking.
A clear explanation of solving Knight Dialer using dynamic programming over the phone keypad graph.
A clear explanation of solving Minimum Falling Path Sum using dynamic programming over matrix rows.
A clear explanation of solving Flip String to Monotone Increasing with a one-pass dynamic programming approach.
A dynamic programming solution for counting binary trees where every non-leaf node is the product of its children.
A dynamic programming solution for finding the shortest instruction sequence that drives a race car to the target position.
A dynamic programming and prefix sum solution for partitioning an array into adjacent groups with maximum total average.
A probability dynamic programming solution for computing whether soup A empties before soup B, with an early return for large input.
A dynamic programming solution for deciding whether an array can be split into two non-empty groups with the same average.
A dynamic programming solution for finding the minimum number of same-index swaps needed to make two arrays strictly increasing.
A clear explanation of simulating overflow in a champagne glass pyramid using dynamic programming.
A clear explanation of counting tilings of a 2 x n board using dominoes and L-shaped trominoes with dynamic programming.
A clear explanation of finding the cheapest flight route with at most k stops using bounded Bellman-Ford relaxation.
A clear explanation of finding the largest plus sign in a mined grid using four directional dynamic programming scans.
A clear explanation of finding the longest common contiguous subarray using dynamic programming.
A clear explanation of maximizing stock trading profit with unlimited transactions and a fixed transaction fee using dynamic programming.
A clear explanation of using dynamic programming to minimize the ASCII cost of deletions needed to make two strings equal.
Find the minimum cost to reach the top of the staircase using dynamic programming.
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.
Count distinct non-empty palindromic subsequences using interval dynamic programming and duplicate handling.
Find the shortest substring of s1 that contains s2 as a subsequence using dynamic programming.
Decide whether an array can be divided into k non-empty subsets with equal sums using backtracking and pruning.
Find the minimum number of stickers needed to form a target string using top-down dynamic programming with memoization.
Find three non-overlapping subarrays of length k with maximum total sum and return the lexicographically smallest starting indices.
Compute the probability that a knight remains on an n x n chessboard after exactly k random moves using dynamic programming.
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 minimizing printer turns using interval dynamic programming.
A clear explanation of finding the minimum-cost path with bounded jumps, blocked cells, and lexicographic tie-breaking.
A dynamic programming solution for maximizing the number of A characters printed with a limited number of keyboard operations.
A dynamic programming and prime factorization solution for finding the minimum operations needed to produce n characters.
A greedy interval scheduling solution for finding the longest chain of valid pairs.
A dynamic programming solution for counting decodings of a digit string with wildcard characters.
A DFS and memoization solution for finding the minimum cost to satisfy item needs using individual prices and reusable special offers.
A dynamic programming and combinatorics solution for counting permutations with no fixed positions.
A dynamic programming solution for counting permutations of 1 to n with exactly k inverse pairs.
A clear explanation of Jump Game II using a greedy range expansion approach to find the minimum number of jumps.
A clear explanation of Wildcard Matching using dynamic programming over string and pattern prefixes.
A clear explanation of the Trapping Rain Water problem using left and right boundaries, then an optimized two-pointer solution.
A clear digit dynamic programming solution for counting numbers whose binary representation does not contain consecutive ones.
A clear dynamic programming solution for finding the minimum deletions needed to make two strings equal.
A clear dynamic programming solution for counting paths that move a ball out of a grid boundary.
A clear explanation of Maximum Vacation Days using dynamic programming over weeks and cities.
A clear explanation of Longest Line of Consecutive One in Matrix using dynamic programming over four directions.
A clear explanation of Student Attendance Record II using dynamic programming over absence count and late streak.
A clear explanation of finding the longest increasing or decreasing consecutive path in a binary tree using DFS.
A clear explanation of maximizing remove-box scores using interval dynamic programming with memoization.
A clear explanation of computing the distance to the nearest zero in a binary matrix using multi-source BFS.
A clear explanation of counting beautiful arrangements using backtracking and divisibility pruning.
A clear explanation of counting coin-change combinations using dynamic programming.
A clear explanation of finding the minimum steps to spell a key on a circular ring using dynamic programming and memoized DFS.
A clear explanation of finding the length of the longest palindromic subsequence using interval dynamic programming.
A clear explanation of computing Fibonacci numbers using dynamic programming and iterative state transitions.
A clear explanation of counting sign assignments that reach a target using recursion first, then subset-sum dynamic programming.
A clear explanation of predicting whether Player 1 can win using minimax dynamic programming over score difference.
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 finding all words that can be formed by concatenating at least two shorter words from the same list.
A clear explanation of interval dynamic programming for encoding a string into the shortest k[encoded_string] form.
A clear explanation of counting unique substrings that appear in the infinite alphabet wraparound string using dynamic programming by ending character.
A clear explanation of counting how many repeated copies of one string can be obtained as a subsequence of another repeated string.
A clear explanation of solving the Can I Win game using minimax recursion, bitmask state compression, and memoization.
Count arithmetic subsequences of length at least three using dynamic programming with one hash map per ending index.
A clear explanation of fitting a sentence onto a screen using cyclic string simulation and greedy row transitions.
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 counting arithmetic subarrays using dynamic programming and consecutive differences.
A clear explanation of the Frog Jump problem using dynamic programming with reachable jump sizes.
A clear explanation of minimizing the largest subarray sum using binary search on the answer and greedy validation.
A clear explanation of maximizing the rotation function using a recurrence instead of simulating every rotation.
A clear explanation of checking whether one string is a subsequence of another using two pointers.
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 minimum guaranteed cost using interval dynamic programming.
A clear explanation of finding the largest subset where every pair is divisible using sorting, dynamic programming, and parent reconstruction.
A clear explanation of finding the best bomb placement in a grid using cached row and column segment counts.
A clear explanation of counting numbers with unique digits using combinatorics.
A clear explanation of solving Russian Doll Envelopes using sorting and longest increasing subsequence.
A clear explanation of Integer Break using dynamic programming, with a note on the greedy math solution.
A clear explanation of Counting Bits using dynamic programming and bit manipulation.
A clear explanation of House Robber III using tree dynamic programming with rob and skip states.
A clear explanation of Longest Increasing Path in a Matrix using DFS with memoization.
A clear explanation of Coin Change using dynamic programming for minimum coin count.
A clear explanation of Super Ugly Number using dynamic programming with one pointer per prime.
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 2D - Immutable using a 2D prefix sum matrix for constant-time rectangle queries.
A dynamic programming and patience sorting solution for finding the longest strictly increasing subsequence in an array.
A dynamic programming solution for finding the least number of perfect square numbers that sum to n.
A dynamic programming solution for counting ways to paint fence posts with no more than two adjacent posts sharing the same color.
A clear explanation of the Paint House II problem using optimized dynamic programming with minimum and second minimum tracking.
A clear explanation of the Ugly Number II problem using dynamic programming with three pointers.
A clear explanation of the Paint House problem using dynamic programming with constant space.
A clear explanation of finding the largest square of 1s in a binary matrix using dynamic programming.
A clear explanation of maximizing robbed money from circularly arranged houses using dynamic programming.
A detailed guide to solving Interleaving String with two-dimensional dynamic programming.
A detailed guide to solving Unique Binary Search Trees with dynamic programming and the Catalan recurrence.
A detailed guide to solving Unique Binary Search Trees II with recursive tree generation over value ranges.
A detailed guide to solving Decode Ways with dynamic programming and careful handling of zeroes.
A detailed guide to solving Scramble String with recursive dynamic programming and memoization.
A detailed guide to solving Maximal Rectangle by converting each matrix row into a histogram and applying a monotonic stack.
A clear explanation of maximizing robbery profit without robbing adjacent houses using dynamic programming.
A clear explanation of maximizing stock trading profit with at most k transactions using dynamic programming.
A clear explanation of computing the minimum initial health needed to survive a dungeon using reverse dynamic programming.
A detailed explanation of tracking both maximum and minimum products while scanning the array.
Return all valid sentences formed by inserting spaces into a string so every word belongs to the dictionary, using DFS with memoization.
Decide whether a string can be segmented into dictionary words using dynamic programming over prefixes.
Find the minimum number of cuts needed to split a string into palindromic substrings using palindrome precomputation and dynamic programming.
Generate all ways to split a string so that every piece is a palindrome, using backtracking with palindrome precomputation.
A clear explanation of finding the maximum path sum in a binary tree using bottom-up depth-first search.
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 explanation of counting distinct subsequences using dynamic programming.
A clear guide to computing the minimum number of insert, delete, and replace operations needed to convert one string into another.
A clear guide to counting distinct ways to climb stairs using dynamic programming.
A clear guide to finding the minimum path sum in a grid using dynamic programming.
A clear guide to counting unique paths in a grid with obstacles using dynamic programming.
A clear guide to counting unique paths in a grid using dynamic programming.
A clear guide to solving Jump Game with greedy reachability.
A clear guide to solving Maximum Subarray with brute force first, then Kadane's dynamic programming algorithm.
A clear explanation of finding the longest well-formed parentheses substring using a stack of indices.
A detailed explanation of matching a full string against a simplified regular expression with dot and star using dynamic programming.
Dynamic programming solves problems by storing answers to subproblems and reusing them.