String
LeetCode 389: Find the Difference
·1 min
LeetCode
Easy
Hash-Table
String
Bit-Manipulation
Sorting
LeetCode 389 note: t has one extra character; XOR every character of both strings, pairs cancel, and the extra one remains
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
LeetCode 383: Ransom Note
·1 min
LeetCode
Easy
Hash-Table
String
Counting
LeetCode 383 note: every character’s demand in ransomNote must not exceed its supply in magazine; an empty Counter difference means yes
LeetCode 345: Reverse Vowels of a String
·1 min
LeetCode
Easy
Two-Pointers
String
LeetCode 345 note: the same two pointers as LC 917, with the condition switched to “is a vowel” (both cases)
LeetCode 344: Reverse String
·1 min
LeetCode
Easy
Two-Pointers
String
LeetCode 344 note: swap with two pointers and move inward to reverse in place
LeetCode 290: Word Pattern
·1 min
LeetCode
Easy
Hash-Table
String
LeetCode 290 note: pattern characters and words must correspond one to one; use two dicts or compare set sizes
LeetCode 257: Binary Tree Paths
·1 min
LeetCode
Easy
String
Backtracking
Tree
Depth-First-Search
LeetCode 257 note: DFS carrying the path string down, adding the whole path at each leaf
LeetCode 242: Valid Anagram
·2 mins
LeetCode
Easy
Hash-Table
String
Sorting
LeetCode 242 note: two strings are anagrams exactly when their character counts match; compare Counters or sorted strings
LeetCode 205: Isomorphic Strings
·2 mins
LeetCode
Easy
Hash-Table
String
LeetCode 205 note: characters must map one to one; it holds when the distinct characters and distinct pairs all have the same count
LeetCode 171: Excel Sheet Column Number
·1 min
LeetCode
Easy
Math
String
LeetCode 171 note: scan left to right with res = res × 26 + letter value (A = 1)
LeetCode 168: Excel Sheet Column Title
·2 mins
LeetCode
Easy
Math
String
LeetCode 168 note: Excel columns are base 26 without a zero digit; take (n - 1) % 26 as the letter, then n = (n - 1) // 26
LeetCode 125: Valid Palindrome
·2 mins
LeetCode
Easy
Two-Pointers
String
LeetCode 125 note: two pointers skip non-alphanumeric characters and compare lowercase letters, with digits included