LeetCode
LeetCode 1446: Consecutive Characters
·1 min
LeetCode
Easy
String
LeetCode 1446 note: track the current run of equal characters in one pass, resetting to 1 on a change
LeetCode 412: Fizz Buzz
·1 min
LeetCode
Easy
Math
String
Simulation
LeetCode 412 note: check multiples of 15 first, then 5 and 3; multiples need %, not //
LeetCode 409: Longest Palindrome
·2 mins
LeetCode
Easy
Hash-Table
String
Greedy
LeetCode 409 note: use an even number of each character on the two sides, plus one in the middle if any count is odd
LeetCode 405: Convert a Number to Hexadecimal
·2 mins
LeetCode
Easy
Math
String
Bit-Manipulation
LeetCode 405 note: add 2^32 to a negative number to get its two’s complement, then take 4 bits at a time (% 16); handle 0 separately
LeetCode 404: Sum of Left Leaves
·1 min
LeetCode
Easy
Tree
Depth-First-Search
Breadth-First-Search
Binary-Tree
LeetCode 404 note: tell each child during DFS whether it is a left child, adding only left children that are leaves
LeetCode 392: Is Subsequence
·2 mins
LeetCode
Easy
Two-Pointers
String
Dynamic-Programming
LeetCode 392 note: two pointers; the pointer on t always advances, and the one on s advances on a match; bound-check both
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 374: Guess Number Higher or Lower
·1 min
LeetCode
Easy
Binary-Search
Interactive
LeetCode 374 note: adjust the range by guess’s result, where -1 means the guess is too high and 1 too low
LeetCode 367: Valid Perfect Square
·1 min
LeetCode
Easy
Math
Binary-Search
LeetCode 367 note: binary search [1, num] for mid² == num without using sqrt
LeetCode 350: Intersection of Two Arrays II
·1 min
LeetCode
Easy
Array
Hash-Table
Two-Pointers
Binary-Search
LeetCode 350 note: an intersection keeping multiplicity, where Counter’s & takes the smaller count from each side