LeetCode
LeetCode 2875: Minimum Size Subarray in Infinite Array
·2 mins
LeetCode
Medium
Sliding-Window
Prefix-Sum
Hash-Table
Array
LeetCode 2875 note: strip target // sum full cycles; the remainder is smaller than one cycle, so a sliding window over two copies of nums always finds it
LeetCode 2302: Count Subarrays With Score Less Than K
·2 mins
LeetCode
Hard
Sliding-Window
Prefix-Sum
Binary-Search
Array
LeetCode 2302 note: score = sum × length with positive numbers grows with the window; shrink while the score is >= k, and right - left + 1 valid subarrays end at right
LeetCode 1234: Replace the Substring for Balanced String
·2 mins
LeetCode
Medium
Sliding-Window
String
LeetCode 1234 note: after replacing a window, every character outside it must be at most n / 4; a shortest-window slide tracks the counts outside the window
LeetCode 1040: Moving Stones Until Consecutive II
·3 mins
LeetCode
Medium
Sliding-Window
Math
Sorting
Array
LeetCode 1040 note: max moves = total gaps minus the edge gap the first move wastes; min moves uses a length-n window holding the most stones, with a special case of 2 when n - 1 stones are already consecutive and one is far away
LeetCode 395: Longest Substring with At Least K Repeating Characters
·3 mins
LeetCode
Medium
Sliding-Window
Divide-and-Conquer
Hash-Table
String
LeetCode 395 note: “every character at least k times” is not monotonic, so a direct slide fails; divide and conquer splits on characters with fewer than k occurrences, or fixing the number of distinct characters makes the window slidable
LeetCode 3810: Minimum Operations to Reach Target Array
·2 mins
LeetCode
Medium
Greedy
Hash-Table
Array
LeetCode 3810 note: one operation fixes every position holding a value, so the answer is the number of distinct values at mismatched positions
LeetCode 3809: Best Reachable Tower
·1 min
LeetCode
Medium
Array
LeetCode 3809 note: keep towers within the Manhattan radius and take the minimum by (-quality, x, y), which also handles ties
LeetCode 1763: Longest Nice Substring
·2 mins
LeetCode
Easy
Sliding-Window
Divide-and-Conquer
Hash-Table
String
Bit-Manipulation
LeetCode 1763 note: a character whose other case never appears cannot be in the answer, so split on it and recurse, preferring the left side on ties
LeetCode 3413: Maximum Coins From K Consecutive Bags
·3 mins
LeetCode
Medium
Sliding-Window
Greedy
Sorting
Prefix-Sum
Binary-Search
Array
LeetCode 3413 note: the best k bags always have one end on a segment boundary; compute “left end at a segment start” and “right end at a segment end” (the latter by mirroring and reusing the same function)
LeetCode 2781: Length of the Longest Valid Substring
·3 mins
LeetCode
Hard
Sliding-Window
Hash-Table
String
Trie
LeetCode 2781 note: forbidden words are at most 10 long, so each right end checks only the last 10 suffixes; on a match push the left end past it, using the shortest match (the rightmost start)
LeetCode 2009: Minimum Number of Operations to Make Array Continuous
·2 mins
LeetCode
Hard
Sliding-Window
Hash-Table
Binary-Search
Array
LeetCode 2009 note: the result is n consecutive integers; after deduplicating and sorting, a sliding window finds the most distinct values within a span of n - 1, and the rest must change
LeetCode 2555: Maximize Win From Two Segments
·2 mins
LeetCode
Medium
Sliding-Window
Binary-Search
Array
LeetCode 2555 note: a sliding window gives how many prizes a segment ending at each prize collects, and a running “best single segment among the first i prizes” supplies the second segment to its left