↓Skip to main content

LeetCode

LeetCode 3325: Count Substrings With K-Frequency Characters I
·2 mins
LeetCode Medium Sliding-Window Hash-Table String
LeetCode 3325 note: an “at least one character appears k times” counting window; when the new character reaches k, keep shrinking until it drops to k - 1
LeetCode 2962: Count Subarrays Where Max Element Appears at Least K Times
·2 mins
LeetCode Medium Sliding-Window Array
LeetCode 2962 note: an “at least k” counting window: keep shrinking while the max appears k times, after which every left end in [0, left) is valid, so count += left
LeetCode 2762: Continuous Subarrays
·2 mins
LeetCode Medium Sliding-Window Monotonic-Queue
LeetCode 2762 note: a sliding window with two monotonic queues for the window maximum and minimum
LeetCode 1358: Number of Substrings Containing All Three Characters
·2 mins
LeetCode Medium Sliding-Window Hash-Table String
LeetCode 1358 note: an “at least one each of a, b, c” counting window: keep shrinking while all three are present, then count += left
LeetCode 632: Smallest Range Covering Elements from K Lists
·3 mins
LeetCode Hard Heap K-Way-Merge Sliding-Window
LeetCode 632 note: a heap of each list’s current element plus the running maximum; always advance the smallest
LeetCode 3816: Lexicographically Smallest String After Deleting Duplicate Characters
·3 mins
LeetCode Hard Stack Monotonic-Stack Greedy String
LeetCode 3816 note: a monotonic stack that deletes a larger top while another copy exists, then trims duplicate letters off the end since a prefix is always smaller
LeetCode 3815: Design Auction System
·3 mins
LeetCode Medium Heap Design Hash-Map Lazy-Deletion
LeetCode 3815 note: one max-heap per item, push a new entry on every bid change, and drop stale entries on query
LeetCode 3814: Maximum Capacity Within Budget
·2 mins
LeetCode Medium Binary-Search Sorting Prefix-Sum
LeetCode 3814 note: sort by cost with a prefix maximum of capacity, and bisect the most expensive partner for each machine
LeetCode 3813: Vowel-Consonant Score
·1 min
LeetCode Easy String Simulation
LeetCode 3813 note: count letters only, split into vowels and consonants; the score is 0 with no consonants, otherwise integer division
LeetCode 3258: Count Substrings That Satisfy K-Constraint I
·2 mins
LeetCode Easy Sliding-Window String
LeetCode 3258 note: valid means zeros <= k or ones <= k; it is invalid only when both exceed k, and after shrinking there are right - left + 1 valid substrings ending at right
LeetCode 2968: Apply Operations to Maximize Frequency Score
·2 mins
LeetCode Hard Sliding-Window Sorting Prefix-Sum Binary-Search Array
LeetCode 2968 note: after sorting, the cheapest common target for a block is its median; prefix sums give the cost in O(1), and it grows with the window, so slide
LeetCode 2904: Shortest and Lexicographically Smallest Beautiful String
·2 mins
LeetCode Medium Sliding-Window String
LeetCode 2904 note: with exactly k ones in the window, also shrink away leading zeros to get the shortest beautiful substring ending at right; compare by length first, then lexicographically