Easy
LeetCode 2269: Find the K-Beauty of a Number
·2 mins
LeetCode
Easy
Sliding-Window
Math
String
LeetCode 2269 note: convert the number to a string and check every length-k substring; 0 cannot be a divisor
LeetCode 2200: Find All K-Distant Indices in an Array
·2 mins
LeetCode
Easy
Two-Pointers
Array
LeetCode 2200 note: extend each key k positions both ways, and keep a pointer to how far output has gone so overlapping ranges are not emitted twice
LeetCode 3794: Reverse String Prefix
·2 mins
LeetCode
Easy
Two-Pointers
String
LeetCode 3794 note: one line with slicing; a hand-written two-pointer version must convert the string to a list first
LeetCode 584: Find Customer Referee
·1 min
LeetCode
Easy
Database
Sql
LeetCode 584 note: referee_id != 2 misses NULLs, since comparing with NULL is unknown; add IS NULL explicitly
LeetCode 1757: Recyclable and Low Fat Products
·1 min
LeetCode
Easy
Database
Sql
LeetCode 1757 note: both conditions must hold, so filter with WHERE … AND …
LeetCode 1281: Subtract the Product and Sum of Digits of an Integer
·1 min
LeetCode
Easy
Math
LeetCode 1281 note: walk the digits once, accumulating product and sum, and return product minus sum
LeetCode 1512: Number of Good Pairs
·1 min
LeetCode
Easy
Math
Hash-Table
Counting
Array
LeetCode 1512 note: count while scanning; each number pairs with every earlier equal number, so add its current count to the answer
LeetCode 1486: XOR Operation in an Array
·1 min
LeetCode
Easy
Math
Bit-Manipulation
LeetCode 1486 note: generate start + 2i by definition and XOR them together
LeetCode 2469: Convert the Temperature
·1 min
LeetCode
Easy
Math
LeetCode 2469 note: apply the formulas directly, Kelvin = C + 273.15 and Fahrenheit = C × 1.8 + 32
LeetCode 2413: Smallest Even Multiple
·1 min
LeetCode
Easy
Math
Number-Theory
LeetCode 2413 note: lcm(2, n), which is n when n is even and 2n when odd
LeetCode 2236: Root Equals Sum of Children
·1 min
LeetCode
Easy
Tree
Binary-Tree
LeetCode 2236 note: a warm-up, plus practice with C++ pointer access
LeetCode 2235: Add Two Integers
·1 min
LeetCode
Easy
Math
LeetCode 2235 note: return the sum; the C++ version once failed to compile from a missing semicolon