Hash-Table
LeetCode 1410: HTML Entity Parser
·2 mins
LeetCode
Medium
Hash-Table
String
LeetCode 1410 note: scan left to right, trying all six entities at each position and skipping past a match; chained replace does not work
LeetCode 3606: Coupon Code Validator
·2 mins
LeetCode
Easy
Hash-Table
String
Sorting
LeetCode 3606 note: filter valid coupons, then sort by (category order, code); character ranges must include z, Z and 9
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 2094: Finding 3-Digit Even Numbers
·2 mins
LeetCode
Easy
Hash-Table
Enumeration
Array
LeetCode 2094 note: enumerate the even numbers 100 to 998 instead and check that each digit needed is available; Counter subtraction keeps only positives
LeetCode 3545: Minimum Deletions for At Most K Distinct Characters
·1 min
LeetCode
Easy
Greedy
Hash-Table
String
Sorting
Counting
LeetCode 3545 note: reducing the number of kinds means deleting whole kinds, starting from the least frequent
LeetCode 952: Largest Component Size by Common Factor
·2 mins
LeetCode
Hard
Math
Number-Theory
Union-Find
Hash-Table
Array
LeetCode 952 note: sharing a factor ⇔ sharing a prime factor; factor each number and union indices with the same prime factor using Union-Find, with no pairwise GCDs
LeetCode 3541: Find Most Frequent Vowel and Consonant
·1 min
LeetCode
Easy
Hash-Table
String
Counting
LeetCode 3541 note: count characters, take the maximum among vowels and among consonants and add them; a missing class counts as 0
LeetCode 3518: Smallest Palindromic Rearrangement II
·3 mins
LeetCode
Hard
Math
Combinatorics
Counting
Hash-Table
String
LeetCode 3518 note: a palindrome is determined by its left half, so this is the k-th permutation of a multiset; try characters position by position and use permutation counts, updated in O(1), to find k’s branch
LeetCode 3487: Maximum Unique Subarray Sum After Deletion
·2 mins
LeetCode
Easy
Greedy
Hash-Table
Array
LeetCode 3487 note: free deletion means picking distinct values; take every non-negative one, or only the maximum when all are negative
LeetCode 3121: Count the Number of Special Characters II
·2 mins
LeetCode
Medium
Hash-Table
String
LeetCode 3121 note: track each letter’s last lowercase index and first uppercase index; it counts only when the former comes first
LeetCode 3120: Count the Number of Special Characters I
·1 min
LeetCode
Easy
Hash-Table
String
LeetCode 3120 note: collect the letters seen in lowercase and in uppercase; the size of their intersection is the answer
LeetCode 1814: Count Nice Pairs in an Array
·1 min
LeetCode
Medium
Array
Hash-Table
Math
Counting
LeetCode 1814 note: rearrange the condition into nums[i] - rev(nums[i]) == nums[j] - rev(nums[j]), count pairs per value, and remember the modulus