Skip to content

LeetCode 03xx

LeetCode practice notes for problems 300 through 399, including A dynamic programming and patience sorting solution for finding the longest strictly increasing subsequence in an array.

#TitleDifficultyDescription
300LeetCode 300: Longest Increasing SubsequenceMediumA dynamic programming and patience sorting solution for finding the longest strictly increasing subsequence in an array.
301LeetCode 301: Remove Invalid ParenthesesHardA clear explanation of Remove Invalid Parentheses using BFS to guarantee the minimum number of removals.
302LeetCode 302: Smallest Rectangle Enclosing Black PixelsHardA clear explanation of Smallest Rectangle Enclosing Black Pixels using binary search on rows and columns.
303LeetCode 303: Range Sum Query - ImmutableEasyA clear explanation of Range Sum Query - Immutable using prefix sums for constant-time range queries.
304LeetCode 304: Range Sum Query 2D - ImmutableMediumA clear explanation of Range Sum Query 2D - Immutable using a 2D prefix sum matrix for constant-time rectangle queries.
305LeetCode 305: Number of Islands IIHardA clear explanation of Number of Islands II using Union-Find to dynamically merge connected land cells.
306LeetCode 306: Additive NumberMediumA clear explanation of Additive Number using split enumeration and deterministic checking.
307LeetCode 307: Range Sum Query - MutableMediumA clear explanation of Range Sum Query - Mutable using a Fenwick Tree for efficient updates and range sums.
308LeetCode 308: Range Sum Query 2D - MutableHardA clear explanation of Range Sum Query 2D - Mutable using a 2D Fenwick Tree for efficient updates and rectangle sum queries.
309LeetCode 309: Best Time to Buy and Sell Stock with CooldownMediumA clear explanation of Best Time to Buy and Sell Stock with Cooldown using dynamic programming states.
310LeetCode 310: Minimum Height TreesMediumA clear explanation of Minimum Height Trees using leaf trimming to find the center of a tree.
311LeetCode 311: Sparse Matrix MultiplicationMediumA clear explanation of Sparse Matrix Multiplication using non-zero entries to avoid wasted work.
312LeetCode 312: Burst BalloonsHardA clear explanation of Burst Balloons using interval dynamic programming and the last-burst idea.
313LeetCode 313: Super Ugly NumberMediumA clear explanation of Super Ugly Number using dynamic programming with one pointer per prime.
314LeetCode 314: Binary Tree Vertical Order TraversalMediumA clear explanation of Binary Tree Vertical Order Traversal using BFS with column indices.
315LeetCode 315: Count of Smaller Numbers After SelfHardA clear explanation of Count of Smaller Numbers After Self using coordinate compression and a Fenwick Tree.
316LeetCode 316: Remove Duplicate LettersMediumA clear explanation of Remove Duplicate Letters using a greedy monotonic stack.
317LeetCode 317: Shortest Distance from All BuildingsHardA clear explanation of Shortest Distance from All Buildings using BFS from each building with distance and reach accumulation.
318LeetCode 318: Maximum Product of Word LengthsMediumA clear explanation of Maximum Product of Word Lengths using bit masks to test disjoint character sets efficiently.
319LeetCode 319: Bulb SwitcherMediumA clear explanation of Bulb Switcher using divisor parity and perfect squares.
320LeetCode 320: Generalized AbbreviationMediumA clear explanation of Generalized Abbreviation using backtracking to choose whether each character is kept or abbreviated.
321LeetCode 321: Create Maximum NumberHardA clear explanation of Create Maximum Number using monotonic stacks for subsequences and greedy merging.
322LeetCode 322: Coin ChangeMediumA clear explanation of Coin Change using dynamic programming for minimum coin count.
323LeetCode 323: Number of Connected Components in an Undirected GraphMediumA clear explanation of counting connected components using Union-Find and graph traversal.
324LeetCode 324: Wiggle Sort IIMediumA clear explanation of Wiggle Sort II using sorting, median splitting, and virtual indexing.
325LeetCode 325: Maximum Size Subarray Sum Equals kMediumA clear explanation of Maximum Size Subarray Sum Equals k using prefix sums and earliest-index hashing.
326LeetCode 326: Power of ThreeEasyA clear explanation of the Power of Three problem using repeated division and integer arithmetic.
327LeetCode 327: Count of Range SumHardA clear explanation of Count of Range Sum using prefix sums and merge sort counting.
328LeetCode 328: Odd Even Linked ListMediumA clear explanation of Odd Even Linked List using in-place pointer rewiring.
329LeetCode 329: Longest Increasing Path in a MatrixHardA clear explanation of Longest Increasing Path in a Matrix using DFS with memoization.
330LeetCode 330: Patching ArrayHardA clear explanation of Patching Array using a greedy smallest-missing-sum invariant.
331LeetCode 331: Verify Preorder Serialization of a Binary TreeMediumA clear explanation of verifying preorder serialization using slot counting without reconstructing the tree.
332LeetCode 332: Reconstruct ItineraryHardA clear explanation of Reconstruct Itinerary using a directed graph and Hierholzer’s algorithm.
333LeetCode 333: Largest BST SubtreeMediumA clear explanation of Largest BST Subtree using postorder traversal and subtree state propagation.
334LeetCode 334: Increasing Triplet SubsequenceMediumA clear explanation of Increasing Triplet Subsequence using greedy tracking of two minimum values.
335LeetCode 335: Self CrossingHardA clear explanation of Self Crossing using constant-space checks for the only possible crossing patterns.
336LeetCode 336: Palindrome PairsHardA clear explanation of Palindrome Pairs using reversed-word lookup and palindrome split checks.
337LeetCode 337: House Robber IIIMediumA clear explanation of House Robber III using tree dynamic programming with rob and skip states.
338LeetCode 338: Counting BitsEasyA clear explanation of Counting Bits using dynamic programming and bit manipulation.
339LeetCode 339: Nested List Weight SumMediumA clear explanation of Nested List Weight Sum using depth-first search over a nested structure.
340LeetCode 340: Longest Substring with At Most K Distinct CharactersMediumA clear explanation of Longest Substring with At Most K Distinct Characters using a sliding window and character counts.
341LeetCode 341: Flatten Nested List IteratorMediumA clear explanation of Flatten Nested List Iterator using lazy stack-based flattening.
342LeetCode 342: Power of FourEasyA clear explanation of Power of Four using bit manipulation and binary properties.
343LeetCode 343: Integer BreakMediumA clear explanation of Integer Break using dynamic programming, with a note on the greedy math solution.
344LeetCode 344: Reverse StringEasyA clear explanation of Reverse String using two pointers and in-place swaps.
345LeetCode 345: Reverse Vowels of a StringEasyA clear explanation of Reverse Vowels of a String using two pointers and selective swaps.
346LeetCode 346: Moving Average from Data StreamEasyA clear explanation of Moving Average from Data Stream using a queue and rolling sum.
347LeetCode 347: Top K Frequent ElementsMediumA clear explanation of Top K Frequent Elements using frequency counting and bucket sort.
348LeetCode 348: Design Tic-Tac-ToeMediumA clear explanation of Design Tic-Tac-Toe using row, column, and diagonal counters for constant-time winner checks.
349LeetCode 349: Intersection of Two ArraysEasyA clear explanation of Intersection of Two Arrays using hash sets for uniqueness and fast lookup.
350LeetCode 350: Intersection of Two Arrays IIEasyA clear explanation of Intersection of Two Arrays II using frequency counting.
351LeetCode 351: Android Unlock PatternsMediumA clear explanation of Android Unlock Patterns using backtracking, a jump table, and symmetry optimization.
352LeetCode 352: Data Stream as Disjoint IntervalsHardA clear explanation of maintaining disjoint sorted intervals from a stream using insertion and merging.
353LeetCode 353: Design Snake GameMediumA clear explanation of implementing Snake Game with a deque for body order and a set for constant-time collision checks.
354LeetCode 354: Russian Doll EnvelopesHardA clear explanation of solving Russian Doll Envelopes using sorting and longest increasing subsequence.
355LeetCode 355: Design TwitterMediumA clear explanation of implementing a simplified Twitter using hash maps, sets, timestamps, and a heap.
356LeetCode 356: Line ReflectionMediumA clear explanation of checking whether 2D points are symmetric around a vertical line using min and max x-coordinates.
357LeetCode 357: Count Numbers with Unique DigitsMediumA clear explanation of counting numbers with unique digits using combinatorics.
358LeetCode 358: Rearrange String k Distance ApartHardA clear explanation of rearranging a string so equal characters are at least k positions apart using a heap and cooldown queue.
359LeetCode 359: Logger Rate LimiterEasyA clear explanation of designing a logger that prints each message at most once every 10 seconds using a hash map.
360LeetCode 360: Sort Transformed ArrayMediumA clear explanation of sorting values after applying a quadratic function using two pointers.
361LeetCode 361: Bomb EnemyMediumA clear explanation of finding the best bomb placement in a grid using cached row and column segment counts.
362LeetCode 362: Design Hit CounterMediumA clear explanation of designing a hit counter for the last 5 minutes using a queue with compressed timestamps.
363LeetCode 363: Max Sum of Rectangle No Larger Than KHardA clear explanation of reducing a 2D rectangle problem to a 1D prefix-sum problem with binary search.
364LeetCode 364: Nested List Weight Sum IIMediumA clear explanation of computing inverse depth weighted sum using level-order traversal.
365LeetCode 365: Water and Jug ProblemMediumA clear explanation of solving the Water and Jug Problem using Bézout’s identity and greatest common divisor.
366LeetCode 366: Find Leaves of Binary TreeMediumA clear explanation of grouping binary tree nodes by the round in which they become leaves using postorder DFS.
367LeetCode 367: Valid Perfect SquareEasyA clear explanation of checking whether an integer is a perfect square using binary search without sqrt.
368LeetCode 368: Largest Divisible SubsetMediumA clear explanation of finding the largest subset where every pair is divisible using sorting, dynamic programming, and parent reconstruction.
369LeetCode 369: Plus One Linked ListMediumA clear explanation of adding one to a number stored as a linked list using the rightmost non-nine digit.
370LeetCode 370: Range AdditionMediumA clear explanation of applying many range updates efficiently using a difference array and prefix sums.
371LeetCode 371: Sum of Two IntegersMediumA clear explanation of adding two integers without using plus or minus by using XOR, AND, carry, and a 32-bit mask.
372LeetCode 372: Super PowMediumA clear explanation of computing large modular exponentiation using fast power, modular arithmetic, and digit decomposition.
373LeetCode 373: Find K Pairs with Smallest SumsMediumA clear explanation of finding the k smallest pair sums from two sorted arrays using a min heap and best-first search.
374LeetCode 374: Guess Number Higher or LowerEasyA clear explanation of finding the picked number using binary search and the guess API.
375LeetCode 375: Guess Number Higher or Lower IIMediumA clear explanation of finding the minimum guaranteed cost using interval dynamic programming.
376LeetCode 376: Wiggle SubsequenceMediumA clear explanation of the Wiggle Subsequence problem using dynamic programming intuition and an optimized greedy solution.
377LeetCode 377: Combination Sum IVMediumA clear explanation of Combination Sum IV using dynamic programming to count ordered combinations that sum to a target.
378LeetCode 378: Kth Smallest Element in a Sorted MatrixMediumA clear explanation of finding the kth smallest value in a row-sorted and column-sorted matrix using binary search on values.
379LeetCode 379: Design Phone DirectoryMediumA clear explanation of designing a phone directory that can allocate, check, and release numbers efficiently.
380LeetCode 380: Insert Delete GetRandom O(1)MediumA clear explanation of designing a randomized set with average O(1) insert, remove, and getRandom operations.
381LeetCode 381: Insert Delete GetRandom O(1) - Duplicates AllowedHardA clear explanation of designing a randomized multiset with average O(1) insert, remove, and getRandom operations.
382LeetCode 382: Linked List Random NodeMediumA clear explanation of selecting a random linked list node with equal probability using reservoir sampling.
383LeetCode 383: Ransom NoteEasyA clear explanation of checking whether one string can be constructed from another using character frequency counting.
384LeetCode 384: Shuffle an ArrayMediumA clear explanation of shuffling an array uniformly using the Fisher-Yates algorithm while supporting reset.
385LeetCode 385: Mini ParserMediumA clear explanation of parsing a serialized nested integer string using a stack.
386LeetCode 386: Lexicographical NumbersMediumA clear explanation of generating numbers from 1 to n in lexicographical order using an iterative DFS-style traversal.
387LeetCode 387: First Unique Character in a StringEasyA clear explanation of finding the first non-repeating character in a string using character frequency counting.
388LeetCode 388: Longest Absolute File PathMediumA clear explanation of computing the longest absolute path to a file from a serialized file system string using path lengths by depth.
389LeetCode 389: Find the DifferenceEasyA clear explanation of finding the extra character added to a shuffled string using counting and XOR.
390LeetCode 390: Elimination GameMediumA clear explanation of finding the last remaining number after alternating left-to-right and right-to-left eliminations.
391LeetCode 391: Perfect RectangleHardA clear explanation of checking whether many small axis-aligned rectangles form one exact rectangular cover using area and corner parity.
392LeetCode 392: Is SubsequenceEasyA clear explanation of checking whether one string is a subsequence of another using two pointers.
393LeetCode 393: UTF-8 ValidationMediumA clear explanation of validating a byte sequence as UTF-8 using bit masks and a continuation-byte counter.
394LeetCode 394: Decode StringMediumA clear explanation of decoding nested repeat expressions using a stack.
395LeetCode 395: Longest Substring with At Least K Repeating CharactersMediumA clear explanation of finding the longest substring where every character appears at least k times using divide and conquer.
396LeetCode 396: Rotate FunctionMediumA clear explanation of maximizing the rotation function using a recurrence instead of simulating every rotation.
397LeetCode 397: Integer ReplacementMediumA clear explanation of reducing an integer to 1 with the fewest operations using greedy bit decisions.
398LeetCode 398: Random Pick IndexMediumA clear explanation of picking a uniformly random index for a target value using reservoir sampling, with an alternative hash map approach.
399LeetCode 399: Evaluate DivisionMediumA clear explanation of solving division equations using graph traversal and weighted edges.
LeetCode 300: Longest Increasing SubsequenceA dynamic programming and patience sorting solution for finding the longest strictly increasing subsequence in an array.
3 min
LeetCode 301: Remove Invalid ParenthesesA clear explanation of Remove Invalid Parentheses using BFS to guarantee the minimum number of removals.
7 min
LeetCode 302: Smallest Rectangle Enclosing Black PixelsA clear explanation of Smallest Rectangle Enclosing Black Pixels using binary search on rows and columns.
7 min
LeetCode 303: Range Sum Query - ImmutableA clear explanation of Range Sum Query - Immutable using prefix sums for constant-time range queries.
5 min
LeetCode 304: Range Sum Query 2D - ImmutableA clear explanation of Range Sum Query 2D - Immutable using a 2D prefix sum matrix for constant-time rectangle queries.
6 min
LeetCode 305: Number of Islands IIA clear explanation of Number of Islands II using Union-Find to dynamically merge connected land cells.
7 min
LeetCode 306: Additive NumberA clear explanation of Additive Number using split enumeration and deterministic checking.
6 min
LeetCode 307: Range Sum Query - MutableA clear explanation of Range Sum Query - Mutable using a Fenwick Tree for efficient updates and range sums.
6 min
LeetCode 308: Range Sum Query 2D - MutableA clear explanation of Range Sum Query 2D - Mutable using a 2D Fenwick Tree for efficient updates and rectangle sum queries.
8 min
LeetCode 309: Best Time to Buy and Sell Stock with CooldownA clear explanation of Best Time to Buy and Sell Stock with Cooldown using dynamic programming states.
6 min
LeetCode 310: Minimum Height TreesA clear explanation of Minimum Height Trees using leaf trimming to find the center of a tree.
6 min
LeetCode 311: Sparse Matrix MultiplicationA clear explanation of Sparse Matrix Multiplication using non-zero entries to avoid wasted work.
6 min
LeetCode 312: Burst BalloonsA clear explanation of Burst Balloons using interval dynamic programming and the last-burst idea.
6 min
LeetCode 313: Super Ugly NumberA clear explanation of Super Ugly Number using dynamic programming with one pointer per prime.
5 min
LeetCode 314: Binary Tree Vertical Order TraversalA clear explanation of Binary Tree Vertical Order Traversal using BFS with column indices.
5 min
LeetCode 315: Count of Smaller Numbers After SelfA clear explanation of Count of Smaller Numbers After Self using coordinate compression and a Fenwick Tree.
5 min
LeetCode 316: Remove Duplicate LettersA clear explanation of Remove Duplicate Letters using a greedy monotonic stack.
6 min
LeetCode 317: Shortest Distance from All BuildingsA clear explanation of Shortest Distance from All Buildings using BFS from each building with distance and reach accumulation.
6 min
LeetCode 318: Maximum Product of Word LengthsA clear explanation of Maximum Product of Word Lengths using bit masks to test disjoint character sets efficiently.
5 min
LeetCode 319: Bulb SwitcherA clear explanation of Bulb Switcher using divisor parity and perfect squares.
4 min
LeetCode 320: Generalized AbbreviationA clear explanation of Generalized Abbreviation using backtracking to choose whether each character is kept or abbreviated.
5 min
LeetCode 321: Create Maximum NumberA clear explanation of Create Maximum Number using monotonic stacks for subsequences and greedy merging.
8 min
LeetCode 322: Coin ChangeA clear explanation of Coin Change using dynamic programming for minimum coin count.
5 min
LeetCode 323: Number of Connected Components in an Undirected GraphA clear explanation of counting connected components using Union-Find and graph traversal.
5 min
LeetCode 324: Wiggle Sort IIA clear explanation of Wiggle Sort II using sorting, median splitting, and virtual indexing.
5 min
LeetCode 325: Maximum Size Subarray Sum Equals kA clear explanation of Maximum Size Subarray Sum Equals k using prefix sums and earliest-index hashing.
5 min
LeetCode 326: Power of ThreeA clear explanation of the Power of Three problem using repeated division and integer arithmetic.
4 min
LeetCode 327: Count of Range SumA clear explanation of Count of Range Sum using prefix sums and merge sort counting.
7 min
LeetCode 328: Odd Even Linked ListA clear explanation of Odd Even Linked List using in-place pointer rewiring.
6 min
LeetCode 329: Longest Increasing Path in a MatrixA clear explanation of Longest Increasing Path in a Matrix using DFS with memoization.
6 min
LeetCode 330: Patching ArrayA clear explanation of Patching Array using a greedy smallest-missing-sum invariant.
7 min
LeetCode 331: Verify Preorder Serialization of a Binary TreeA clear explanation of verifying preorder serialization using slot counting without reconstructing the tree.
5 min
LeetCode 332: Reconstruct ItineraryA clear explanation of Reconstruct Itinerary using a directed graph and Hierholzer's algorithm.
5 min
LeetCode 333: Largest BST SubtreeA clear explanation of Largest BST Subtree using postorder traversal and subtree state propagation.
6 min
LeetCode 334: Increasing Triplet SubsequenceA clear explanation of Increasing Triplet Subsequence using greedy tracking of two minimum values.
5 min
LeetCode 335: Self CrossingA clear explanation of Self Crossing using constant-space checks for the only possible crossing patterns.
6 min
LeetCode 336: Palindrome PairsA clear explanation of Palindrome Pairs using reversed-word lookup and palindrome split checks.
8 min
LeetCode 337: House Robber IIIA clear explanation of House Robber III using tree dynamic programming with rob and skip states.
6 min
LeetCode 338: Counting BitsA clear explanation of Counting Bits using dynamic programming and bit manipulation.
5 min
LeetCode 339: Nested List Weight SumA clear explanation of Nested List Weight Sum using depth-first search over a nested structure.
5 min
LeetCode 340: Longest Substring with At Most K Distinct CharactersA clear explanation of Longest Substring with At Most K Distinct Characters using a sliding window and character counts.
5 min
LeetCode 341: Flatten Nested List IteratorA clear explanation of Flatten Nested List Iterator using lazy stack-based flattening.
6 min
LeetCode 342: Power of FourA clear explanation of Power of Four using bit manipulation and binary properties.
5 min
LeetCode 343: Integer BreakA clear explanation of Integer Break using dynamic programming, with a note on the greedy math solution.
5 min
LeetCode 344: Reverse StringA clear explanation of Reverse String using two pointers and in-place swaps.
4 min
LeetCode 345: Reverse Vowels of a StringA clear explanation of Reverse Vowels of a String using two pointers and selective swaps.
4 min
LeetCode 346: Moving Average from Data StreamA clear explanation of Moving Average from Data Stream using a queue and rolling sum.
4 min
LeetCode 347: Top K Frequent ElementsA clear explanation of Top K Frequent Elements using frequency counting and bucket sort.
5 min
LeetCode 348: Design Tic-Tac-ToeA clear explanation of Design Tic-Tac-Toe using row, column, and diagonal counters for constant-time winner checks.
6 min
LeetCode 349: Intersection of Two ArraysA clear explanation of Intersection of Two Arrays using hash sets for uniqueness and fast lookup.
4 min
LeetCode 350: Intersection of Two Arrays IIA clear explanation of Intersection of Two Arrays II using frequency counting.
5 min
LeetCode 351: Android Unlock PatternsA clear explanation of Android Unlock Patterns using backtracking, a jump table, and symmetry optimization.
7 min
LeetCode 352: Data Stream as Disjoint IntervalsA clear explanation of maintaining disjoint sorted intervals from a stream using insertion and merging.
6 min
LeetCode 353: Design Snake GameA clear explanation of implementing Snake Game with a deque for body order and a set for constant-time collision checks.
7 min
LeetCode 354: Russian Doll EnvelopesA clear explanation of solving Russian Doll Envelopes using sorting and longest increasing subsequence.
4 min
LeetCode 355: Design TwitterA clear explanation of implementing a simplified Twitter using hash maps, sets, timestamps, and a heap.
6 min
LeetCode 356: Line ReflectionA clear explanation of checking whether 2D points are symmetric around a vertical line using min and max x-coordinates.
5 min
LeetCode 357: Count Numbers with Unique DigitsA clear explanation of counting numbers with unique digits using combinatorics.
5 min
LeetCode 358: Rearrange String k Distance ApartA clear explanation of rearranging a string so equal characters are at least k positions apart using a heap and cooldown queue.
6 min
LeetCode 359: Logger Rate LimiterA clear explanation of designing a logger that prints each message at most once every 10 seconds using a hash map.
5 min
LeetCode 360: Sort Transformed ArrayA clear explanation of sorting values after applying a quadratic function using two pointers.
6 min
LeetCode 361: Bomb EnemyA clear explanation of finding the best bomb placement in a grid using cached row and column segment counts.
6 min
LeetCode 362: Design Hit CounterA clear explanation of designing a hit counter for the last 5 minutes using a queue with compressed timestamps.
6 min
LeetCode 363: Max Sum of Rectangle No Larger Than KA clear explanation of reducing a 2D rectangle problem to a 1D prefix-sum problem with binary search.
7 min
LeetCode 364: Nested List Weight Sum IIA clear explanation of computing inverse depth weighted sum using level-order traversal.
5 min
LeetCode 365: Water and Jug ProblemA clear explanation of solving the Water and Jug Problem using Bézout's identity and greatest common divisor.
6 min
LeetCode 366: Find Leaves of Binary TreeA clear explanation of grouping binary tree nodes by the round in which they become leaves using postorder DFS.
5 min
LeetCode 367: Valid Perfect SquareA clear explanation of checking whether an integer is a perfect square using binary search without sqrt.
4 min
LeetCode 368: Largest Divisible SubsetA clear explanation of finding the largest subset where every pair is divisible using sorting, dynamic programming, and parent reconstruction.
5 min
LeetCode 369: Plus One Linked ListA clear explanation of adding one to a number stored as a linked list using the rightmost non-nine digit.
5 min
LeetCode 370: Range AdditionA clear explanation of applying many range updates efficiently using a difference array and prefix sums.
5 min
LeetCode 371: Sum of Two IntegersA clear explanation of adding two integers without using plus or minus by using XOR, AND, carry, and a 32-bit mask.
4 min
LeetCode 372: Super PowA clear explanation of computing large modular exponentiation using fast power, modular arithmetic, and digit decomposition.
4 min
LeetCode 373: Find K Pairs with Smallest SumsA clear explanation of finding the k smallest pair sums from two sorted arrays using a min heap and best-first search.
5 min
LeetCode 374: Guess Number Higher or LowerA clear explanation of finding the picked number using binary search and the guess API.
4 min
LeetCode 375: Guess Number Higher or Lower IIA clear explanation of finding the minimum guaranteed cost using interval dynamic programming.
5 min
LeetCode 376: Wiggle SubsequenceA clear explanation of the Wiggle Subsequence problem using dynamic programming intuition and an optimized greedy solution.
5 min
LeetCode 377: Combination Sum IVA clear explanation of Combination Sum IV using dynamic programming to count ordered combinations that sum to a target.
6 min
LeetCode 378: Kth Smallest Element in a Sorted MatrixA clear explanation of finding the kth smallest value in a row-sorted and column-sorted matrix using binary search on values.
5 min
LeetCode 379: Design Phone DirectoryA clear explanation of designing a phone directory that can allocate, check, and release numbers efficiently.
5 min
LeetCode 380: Insert Delete GetRandom O(1)A clear explanation of designing a randomized set with average O(1) insert, remove, and getRandom operations.
6 min
LeetCode 381: Insert Delete GetRandom O(1) - Duplicates AllowedA clear explanation of designing a randomized multiset with average O(1) insert, remove, and getRandom operations.
6 min
LeetCode 382: Linked List Random NodeA clear explanation of selecting a random linked list node with equal probability using reservoir sampling.
5 min
LeetCode 383: Ransom NoteA clear explanation of checking whether one string can be constructed from another using character frequency counting.
4 min
LeetCode 384: Shuffle an ArrayA clear explanation of shuffling an array uniformly using the Fisher-Yates algorithm while supporting reset.
4 min
LeetCode 385: Mini ParserA clear explanation of parsing a serialized nested integer string using a stack.
5 min
LeetCode 386: Lexicographical NumbersA clear explanation of generating numbers from 1 to n in lexicographical order using an iterative DFS-style traversal.
6 min
LeetCode 387: First Unique Character in a StringA clear explanation of finding the first non-repeating character in a string using character frequency counting.
4 min
LeetCode 388: Longest Absolute File PathA clear explanation of computing the longest absolute path to a file from a serialized file system string using path lengths by depth.
5 min
LeetCode 389: Find the DifferenceA clear explanation of finding the extra character added to a shuffled string using counting and XOR.
4 min
LeetCode 390: Elimination GameA clear explanation of finding the last remaining number after alternating left-to-right and right-to-left eliminations.
5 min
LeetCode 391: Perfect RectangleA clear explanation of checking whether many small axis-aligned rectangles form one exact rectangular cover using area and corner parity.
6 min
LeetCode 392: Is SubsequenceA clear explanation of checking whether one string is a subsequence of another using two pointers.
5 min
LeetCode 393: UTF-8 ValidationA clear explanation of validating a byte sequence as UTF-8 using bit masks and a continuation-byte counter.
6 min
LeetCode 394: Decode StringA clear explanation of decoding nested repeat expressions using a stack.
5 min
LeetCode 395: Longest Substring with At Least K Repeating CharactersA clear explanation of finding the longest substring where every character appears at least k times using divide and conquer.
6 min
LeetCode 396: Rotate FunctionA clear explanation of maximizing the rotation function using a recurrence instead of simulating every rotation.
4 min
LeetCode 397: Integer ReplacementA clear explanation of reducing an integer to 1 with the fewest operations using greedy bit decisions.
5 min
LeetCode 398: Random Pick IndexA clear explanation of picking a uniformly random index for a target value using reservoir sampling, with an alternative hash map approach.
4 min
LeetCode 399: Evaluate DivisionA clear explanation of solving division equations using graph traversal and weighted edges.
6 min