Hard
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 2106: Maximum Fruits Harvested After at Most K Steps
·2 mins
LeetCode
Hard
Sliding-Window
Prefix-Sum
Binary-Search
Array
LeetCode 2106 note: the harvest is always a contiguous block of fruits; covering [L, R] takes (R - L) + min(|start - L|, |R - start|) steps, so slide a window over the fruits array
LeetCode 1458: Max Dot Product of Two Subsequences
·2 mins
LeetCode
Hard
Dynamic-Programming
Longest-Common-Subsequence
Array
LeetCode 1458 note: a two-prefix DP; dp[i][j] either pairs nums1[i] with nums2[j] (extending dp[i-1][j-1] or starting fresh) or skips one of them
LeetCode 220: Contains Duplicate III
·3 mins
LeetCode
Hard
Sliding-Window
Bucket-Sort
Ordered-Set
Sorting
Array
LeetCode 220 note: with bucket size valueDiff + 1, two numbers in one bucket always qualify, so only the two neighboring buckets need checking; the window keeps the latest indexDiff numbers, so each bucket holds at most one
LeetCode 2953: Count Complete Substrings
·3 mins
LeetCode
Hard
Sliding-Window
Hash-Table
String
LeetCode 2953 note: split where neighboring letters differ by more than 2; in each segment enumerate the number of distinct letters d, slide a fixed window of d × k, and track how many letters appear exactly k times
LeetCode 2156: Find Substring With Given Hash Value
·3 mins
LeetCode
Hard
Sliding-Window
Rolling-Hash
String
LeetCode 2156 note: the first character has weight p^0, so sliding right to left needs only multiply by p, add the new character, and subtract the outgoing one times p^k; the modulus may not be prime, so no modular inverse
LeetCode 84: Largest Rectangle in Histogram
·3 mins
LeetCode
Daily
Hard
Array
Stack
Monotonic-Stack
Dynamic-Programming
Geometry
Histogram
Solving the Largest Rectangle in Histogram problem using monotonic stack approach
LeetCode 30: Substring with Concatenation of All Words (Brute Force → Counting → Sliding Window)
·3 mins
LeetCode
Daily
Hard
String
Sliding-Window
Two-Pointers
Hash-Map
Brute-Force
Frequency-Counting
Three approaches: brute force, counting optimization, and sliding window over word-length offsets.
LeetCode 2709: Greatest Common Divisor Traversal
·3 mins
LeetCode
Hard
Math
Number-Theory
Union-Find
Sieve
Gcd
Array
LeetCode 2709 note: every pair of indices connects ⇔ one component; factor with SPF and union each number with its prime factors in Union-Find, treating 1 specially
LeetCode 76: Minimum Window Substring
·3 mins
LeetCode
Daily
Hard
String
Sliding-Window
Variable-Window
Two-Pointers
Hash-Map
LeetCode Problem Solving - Variable Size Sliding Window with Character Counting
LeetCode 135: Candy
·2 mins
LeetCode
Hard
Greedy
Array
LeetCode 135 note: one pass left to right for the left neighbor, one right to left for the right neighbor, and give each child the larger of the two