Skip to Content
LeetCode The Hard Way

0900 - 0999

Solutions categorised by Problem IDs

901 - Online Stock SpanCompute each day's stock span by tracking earlier prices and skipping runs already covered by smaller prices.904 - Fruit Into BasketsFind the longest run containing at most two fruit types by sliding a window along the row of trees.907 - Sum of Subarray MinimumsSum all subarray minimums by using a stack to determine how many subarrays each element represents.909 - Snakes and LaddersFind the fewest dice throws needed to reach the final square while accounting for forced snake and ladder moves.912 - Sort an ArrayCompare sorting methods for an integer array, including quicksort, merge sort, counting sort, and Shell sort.918 - Maximum Sum Circular SubarrayFind the maximum circular subarray sum by comparing a standard maximum subarray with a wraparound candidate.923 - 3Sum With MultiplicityCount index triples with a target sum by combining value frequencies and accounting for repeated values.926 - Flip String to Monotone IncreasingMinimize flips to make a binary string monotone increasing by tracking the best cost as each bit is processed.935 - Knight DialerCount keypad sequences a knight can dial by modeling legal jumps as transitions between digit states.936 - Stamping The SequenceConstruct a stamping sequence by working backward and erasing target positions that match a possible stamp placement.941 - Valid Mountain ArrayValidate a mountain array by checking for a strictly rising stretch followed by a strictly falling stretch.944 - Delete Columns to Make SortedCount the matrix columns that violate alphabetical order by comparing adjacent characters down each column.946 - Validate Stack SequencesTest whether a pop sequence is possible by simulating stack pushes and matching each available pop.947 - Most Stones Removed with Same Row or ColumnMaximize stone removals by joining stones that share a row or column and counting the resulting connected components.948 - Bag of TokensMaximize token score by spending power on cheaper tokens and trading expensive tokens for power when needed.952 - Largest Component Size by Common FactorFind the largest component linked by common factors by factoring the values and merging related elements with disjoint sets.967 - Numbers With Same Consecutive DifferencesGenerate numbers whose neighboring digits differ by k by extending valid prefixes with breadth-first search.973 - K Closest Points to OriginSelect the k points nearest the origin by comparing squared distances with a heap or quickselect.974 - Subarray Sums Divisible by KCount subarrays divisible by k by grouping prefix sums that share a remainder.976 - Largest Perimeter TriangleFind the largest triangle perimeter by sorting the side lengths and testing neighboring triples against the triangle inequality.977 - Squares of a Sorted ArrayProduce sorted squares from a sorted array by comparing the absolute values at its two ends.981 - Time Based Key-Value StoreStore values by key and timestamp, then binary search for the latest value available at a query time.985 - Sum of Even Numbers After QueriesUpdate the sum of even array values after each query by accounting for the changed value before and after the update.987 - Vertical Order Traversal of a Binary TreeTraverse a binary tree by vertical columns, using row positions and node values to break ordering ties.990 - Satisfiability of Equality EquationsDecide whether variable equalities and inequalities can coexist by joining equal variables with disjoint sets.991 - Broken CalculatorMinimize broken-calculator operations by working backward from the target with greedy inverse operations.992 - Subarrays with K Different IntegersCount subarrays containing exactly k distinct integers by tracking distinct values in sliding windows.994 - Rotting OrangesCompute the minutes needed to rot all reachable oranges by spreading infection from every rotten orange in parallel.