Skip to Content
LeetCode The Hard Way

0400 - 0499

Solutions categorised by Problem IDs

402 - Remove K DigitsRemove k digits to form the smallest possible number by using a monotonic stack to discard larger preceding digits.403 - Frog JumpDecide whether the frog can cross the river by tracking which jump lengths can reach each stone.404 - Sum of Left LeavesSum the values of left leaves by distinguishing them from right children during depth-first traversal.412 - Fizz BuzzGenerate the Fizz Buzz sequence by testing divisibility by three, five, or both at each number.413 - Arithmetic SlicesCount contiguous arithmetic slices by extending runs of equal differences and adding the new slices at each step.416 - Partition Equal Subset SumCheck for two equal-sum subsets by using dynamic programming to search for a subset totaling half the array sum.417 - Pacific Atlantic Water FlowFind cells that drain into both oceans by searching inland from each coast and taking the intersection.421 - Maximum XOR of Two Numbers in an ArrayBuild the largest possible XOR one bit at a time by testing whether two array prefixes can produce each candidate.424 - Longest Repeating Character ReplacementFind the longest substring that can become a single repeated letter by tracking character frequencies in a sliding window.429 - N-ary Tree Level Order TraversalCollect the values at each level of an N-ary tree by processing its children with breadth-first search.433 - Minimum Genetic MutationFind the fewest valid gene mutations by searching the gene bank one single-character change at a time.435 - Non-overlapping IntervalsMinimize interval removals by greedily keeping compatible intervals with room for subsequent choices.437 - Path Sum IIICount downward tree paths with a target sum by considering paths that begin below the root as well as at the root.438 - Find All Anagrams in a StringFind all starting positions of anagrams by comparing letter counts in a fixed-length sliding window.441 - Arranging CoinsFind how many complete coin rows fit in a staircase using triangular numbers or binary search.443 - String CompressionCompress consecutive character runs in place by writing each character and the digits of its repeat count.445 - Add Two Numbers IIAdd numbers stored most-significant-digit first in linked lists by using stacks or recursion to process the final digits first.451 - Sort Characters By FrequencySort characters by occurrence count and rebuild the string with the most frequent characters first.452 - Minimum Number of Arrows to Burst BalloonsFind the fewest arrows needed by grouping overlapping balloon intervals around shared burst positions.453 - Minimum Moves to Equal Array ElementsFind the minimum moves to equalize an array by relating increments of all but one element to differences from the minimum.454 - 4Sum IICount zero-sum quadruples from four arrays by matching sums from two arrays to complementary sums from the other two.462 - Minimum Moves to Equal Array Elements IIMinimize unit moves to equalize an array by sorting the values and measuring their distances to a median.464 - Can I WinDecide whether the first player can force a win by representing the already chosen integers with a bit mask.465 - Optimal Account BalancingGiven a list of transactions, find the smallest number of transfers needed to settle everyone's net balance.472 - Concatenated WordsIdentify words formed by concatenating shorter dictionary words using prefix searches or a set of known words.473 - Matchsticks to SquareDetermine whether matchsticks form a square by tracking subsets of sticks that can fill four equal sides.491 - Non-decreasing SubsequencesGenerate distinct non-decreasing subsequences while filtering out repeated sequences.493 - Reverse PairsCount index pairs whose first value exceeds twice the second using an ordered set or a binary indexed tree.494 - Target SumCount assignments of plus and minus signs that reach a target by memoizing the sums reachable from each position.496 - Next Greater Element IFind each queried number's next greater value by resolving pending elements with a stack and storing their answers.