Two-Pointers
LeetCode 1695: Maximum Erasure Value (Sliding Window)
·1 min
LeetCode
Daily
Medium
Array
Sliding-Window
Two-Pointers
Hash-Set
Sliding window with a set and running sum; two pointers to keep the subarray unique.
LeetCode 2441: Largest Positive Integer That Exists With Its Negative
·2 mins
LeetCode
Easy
Hash-Map
Two-Pointers
Sorting
LeetCode 2441 note: keep positives and absolute values of negatives in separate sets and take the largest common value; absolute values alone mistake same-sign duplicates for pairs
LeetCode 904: Fruit Into Baskets
·3 mins
LeetCode
Daily
Medium
Sliding-Window
Variable-Window
Two-Pointers
Hash-Map
LeetCode Problem Solving - Variable Size Sliding Window with Hash Map
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 1004: Max Consecutive Ones III
·3 mins
LeetCode
Daily
Medium
Array
Sliding-Window
Two-Pointers
Binary-Array
LeetCode Problem Solving - Variable Size Sliding Window with Zero Counting
LeetCode 2410: Maximum Matching of Players With Trainers
·2 mins
LeetCode
Medium
Two-Pointers
Greedy
Sorting
Array
LeetCode 2410 note: sort both sides, then same-direction pointers match the weakest player with the smallest trainer that is good enough
Sliding Window
·8 mins
Algorithm
Sliding-Window
Two-Pointers
Hash-Table
Monotonic-Queue
Fixed-size windows, variable windows for longest / shortest, counting subarrays (at most K minus at most K - 1, count += left for at least K), and monotonic deques for window extremes
LeetCode 1768: Merge Strings Alternately
·2 mins
LeetCode
Easy
Two-Pointers
String
LeetCode 1768 note: take characters in turn with one index, then append whatever remains of the longer string
LeetCode 2000: Reverse Prefix of Word
·1 min
LeetCode
Easy
Two-Pointers
String
Stack
LeetCode 2000 note: find the first index i of ch, reverse word[:i + 1] and append the rest; return the word unchanged if ch is absent
LeetCode 3069: Distribute Elements Into Two Arrays I
·1 min
LeetCode
Easy
Array
Two-Pointers
Simulation
LeetCode 3069 note: simulate the rule: the first two go to separate arrays, then each element joins the array whose last element is larger
LeetCode 611: Valid Triangle Number
·2 mins
LeetCode
Medium
Array
Two-Pointers
Binary-Search
Greedy
LeetCode 611 note: sort, fix the longest side k, and use two pointers for the shorter sides; when the sum is large enough every i in between works, adding j - i at once
LeetCode 165: Compare Version Numbers
·1 min
LeetCode
Medium
Two-Pointers
String
LeetCode 165 note: split on dots, compare revision by revision as integers, and treat missing revisions of the shorter version as 0