Binary-Search
LeetCode 1838: Frequency of the Most Frequent Element
·2 mins
LeetCode
Medium
Sliding-Window
Sorting
Greedy
Prefix-Sum
Binary-Search
Array
LeetCode 1838 note: after sorting, raising the whole window to nums[right] costs nums[right] × length − window sum; shrink the left while that exceeds k
LeetCode 3634: Minimum Removals to Balance Array
·2 mins
LeetCode
Medium
Sliding-Window
Sorting
Binary-Search
Array
LeetCode 3634 note: after sorting, what remains is always a contiguous block; for each minimum nums[left], a right-only pointer finds how far it can extend, and everything outside is removed
LeetCode 2024: Maximize the Confusion of an Exam
·2 mins
LeetCode
Medium
Sliding-Window
String
Binary-Search
Prefix-Sum
LeetCode 2024 note: a window is valid when the rarer of T and F appears at most k times (flip all of them); shrink the left when it is not
LeetCode 1208: Get Equal Substrings Within Budget
·1 min
LeetCode
Medium
Sliding-Window
String
Binary-Search
Prefix-Sum
LeetCode 1208 note: each position costs |s[i] - t[i]|, so the problem becomes the longest subarray with sum <= maxCost
LeetCode 3709: Design Exam Scores Tracker
·2 mins
LeetCode
Medium
Binary-Search
Prefix-Sum
Design
LeetCode 3709 note: times are increasing, so store prefix sums and answer queries with two bisects; always parenthesize mid
LeetCode 2300: Successful Pairs of Spells and Potions
·2 mins
LeetCode
Medium
Binary-Search
Sorting
Two-Pointers
LeetCode 2300 note: sort potions, bisect a threshold per spell, and compute the threshold with integer ceil to avoid float error
LeetCode 209: Minimum Size Subarray Sum (Sliding Window)
·1 min
LeetCode
Daily
Medium
Array
Sliding-Window
Two-Pointers
Prefix-Sum
Binary-Search
Sliding window with two pointers; minimize subarray length where sum ≥ target.
LeetCode 3639: Minimum Time to Activate String
·3 mins
LeetCode
Medium
Binary-Search
Counting
String
LeetCode 3639 note: each new star adds (left distance) × (right distance) new substrings; or binary search on time
LeetCode 3613: Minimize Maximum Component Cost
·2 mins
LeetCode
Medium
Union-Find
Graph
Sorting
Binary-Search
LeetCode 3613 note: add edges from light to heavy; the weight when exactly k components remain is the answer, and 0 when n <= k
LeetCode 3608: Minimum Time for K Connected Components
·2 mins
LeetCode
Medium
Union-Find
Graph
Sorting
Binary-Search
LeetCode 3608 note: add edges back from the largest time; the time of the first edge that drops the component count below k is the answer
LeetCode 3508: Implement Router
·3 mins
LeetCode
Medium
Design
Binary-Search
Queue
Hash-Map
LeetCode 3508 note: a queue for FIFO, a set for duplicates, and an increasing time list per destination queried with bisect
LeetCode 154: Find Minimum in Rotated Sorted Array II
·1 min
LeetCode
Hard
Array
Binary-Search
LeetCode 154 note: compare with the right end as in LC 153; on equality the break could be on either side, so r -= 1, worst case O(n)