Counting
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 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
LeetCode 3071: Minimum Operations to Write the Letter Y on a Grid
·2 mins
LeetCode
Medium
Array
Hash-Table
Matrix
Counting
LeetCode 3071 note: count each value on and off the Y, enumerate the Y value a and background value b (a != b), and take the fewest cells to change
LeetCode 229: Majority Element II
·2 mins
LeetCode
Medium
Array
Hash-Table
Sorting
Counting
LeetCode 229 note: at most two values can exceed n / 3; Boyer-Moore keeps two candidates and a second pass verifies their counts
LeetCode 1189: Maximum Number of Balloons
·2 mins
LeetCode
Easy
Hash-Table
String
Counting
LeetCode 1189 note: each letter supports count // needed balloons, with l and o needed twice; take the minimum
LeetCode 1160: Find Words That Can Be Formed by Characters
·1 min
LeetCode
Easy
Array
Hash-Table
String
Counting
LeetCode 1160 note: a word is formable when none of its character counts exceeds chars’; sum the lengths of such words
LeetCode 1128: Number of Equivalent Domino Pairs
·2 mins
LeetCode
Easy
Array
Hash-Table
Counting
LeetCode 1128 note: normalize each domino to (small, large) as a key and count; a key with c dominoes yields c(c - 1) / 2 pairs
LeetCode 914: X of a Kind in a Deck of Cards
·2 mins
LeetCode
Easy
Array
Hash-Table
Math
Counting
LeetCode 914 note: every card count must be divisible by one X >= 2, i.e. the GCD of all counts is at least 2
LeetCode 884: Uncommon Words from Two Sentences
·1 min
LeetCode
Easy
Hash-Table
String
Counting
LeetCode 884 note: count words across both sentences together; those appearing exactly once are the answer
LeetCode 819: Most Common Word
·2 mins
LeetCode
Easy
Array
Hash-Table
String
Counting
LeetCode 819 note: replace punctuation with spaces, lowercase, split, count, and pick the most frequent word not banned
LeetCode 387: First Unique Character in a String
·1 min
LeetCode
Easy
Hash-Table
String
Queue
Counting
LeetCode 387 note: count first, then scan left to right for the first character with count 1