LeetCode
LeetCode 728: Self Dividing Numbers
·2 mins
LeetCode
Easy
Math
LeetCode 728 note: check every number in the range; each digit must be nonzero and divide the number
LeetCode 709: To Lower Case
·1 min
LeetCode
Easy
String
LeetCode 709 note: an uppercase letter plus 32 in ASCII is its lowercase form; other characters stay
LeetCode 705: Design HashSet
·2 mins
LeetCode
Easy
Array
Hash-Table
Linked-List
Design
LeetCode 705 note: a fixed number of buckets, with the key modulo the bucket count choosing the bucket and a list per bucket handling collisions
LeetCode 704: Binary Search
·2 mins
LeetCode
Easy
Array
Binary-Search
LeetCode 704 note: a closed interval [l, r] with an integer mid; return on a match, otherwise discard the half that cannot contain the target
LeetCode 703: Kth Largest Element in a Stream
·1 min
LeetCode
Easy
Tree
Design
Binary-Search-Tree
Heap-Priority-Queue
LeetCode 703 note: keep a min-heap of size k; its top is the k-th largest
LeetCode 700: Search in a Binary Search Tree
·1 min
LeetCode
Easy
Tree
Binary-Search-Tree
Binary-Tree
LeetCode 700 note: go left when the node is larger, right when smaller, and return the node when found
LeetCode 697: Degree of an Array
·2 mins
LeetCode
Easy
Array
Hash-Table
LeetCode 697 note: record each value’s count, first index and last index; among the most frequent values, take the shortest span
LeetCode 696: Count Binary Substrings
·2 mins
LeetCode
Easy
Two-Pointers
String
LeetCode 696 note: split the string into runs of equal characters; each adjacent pair of runs contributes min(previous, current) substrings
LeetCode 693: Binary Number with Alternating Bits
·1 min
LeetCode
Easy
Bit-Manipulation
LeetCode 693 note: alternating bits means the binary string has neither 00 nor 11; in bits, n ^ (n » 1) is all ones
LeetCode 682: Baseball Game
·1 min
LeetCode
Easy
Array
Stack
Simulation
LeetCode 682 note: keep valid scores on a stack; C removes the last, D adds its double, and + adds the sum of the last two
LeetCode 680: Valid Palindrome II
·2 mins
LeetCode
Easy
Two-Pointers
String
Greedy
LeetCode 680 note: at the first mismatch the only options are deleting the left or the right character; check whether either remainder is a palindrome
LeetCode 674: Longest Continuous Increasing Subsequence
·2 mins
LeetCode
Easy
Array
LeetCode 674 note: one pass that extends the run while strictly increasing and resets to 1 otherwise, updating the maximum after the loop too