Easy
LeetCode 414: Third Maximum Number
·1 min
LeetCode
Easy
Array
Sorting
LeetCode 414 note: track the three largest distinct values, skipping repeats, and return the maximum if fewer than three distinct values exist
LeetCode 1869: Longer Contiguous Segments of Ones than Zeros
·1 min
LeetCode
Easy
String
LeetCode 1869 note: find the longest run of 1s and of 0s and compare; split does it in one line
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