LeetCode
LeetCode 1002: Find Common Characters
·1 min
LeetCode
Easy
Array
Hash-Table
String
LeetCode 1002 note: count each word and intersect all Counters (minimum count per character), then expand
LeetCode 993: Cousins in Binary Tree
·1 min
LeetCode
Easy
Tree
Depth-First-Search
Breadth-First-Search
Binary-Tree
LeetCode 993 note: cousins share a depth but not a parent; record x’s and y’s depth and parent during DFS and compare
LeetCode 989: Add to Array-Form of Integer
·2 mins
LeetCode
Easy
Array
Math
LeetCode 989 note: treat k as the carry, add from the last element backwards, and keep prepending digits while k remains
LeetCode 977: Squares of a Sorted Array
·1 min
LeetCode
Easy
Array
Two-Pointers
Sorting
LeetCode 977 note: the largest squares are at the two ends, so compare the ends with two pointers and fill the result from the back
LeetCode 965: Univalued Binary Tree
·1 min
LeetCode
Easy
Tree
Depth-First-Search
Breadth-First-Search
Binary-Tree
LeetCode 965 note: every value must equal the root’s; compare values while recursing, not the booleans the recursion returns
LeetCode 961: N-Repeated Element in Size 2N Array
·1 min
LeetCode
Easy
Array
Hash-Table
Pigeonhole-Principle
LeetCode 961 note: the other n values are distinct, so the first value seen twice is the answer
LeetCode 953: Verifying an Alien Dictionary
·2 mins
LeetCode
Easy
Array
Hash-Table
String
LeetCode 953 note: map letters to their alien index and compare each adjacent pair at the first differing character; with no difference, the shorter must come first
LeetCode 944: Delete Columns to Make Sorted
·1 min
LeetCode
Easy
Array
String
Longest-Increasing-Subsequence
LeetCode 944 note: take each column with zip(*strs) and count the columns that are not non-decreasing
LeetCode 942: DI String Match
·1 min
LeetCode
Easy
Array
Two-Pointers
String
Greedy
LeetCode 942 note: two pointers hold the smallest and largest unused values; place the smallest on I and the largest on D
LeetCode 941: Valid Mountain Array
·2 mins
LeetCode
Easy
Array
LeetCode 941 note: climb from the left to the peak, then descend; you must reach the end exactly, with the peak not at either end
LeetCode 938: Range Sum of BST
·2 mins
LeetCode
Easy
Tree
Depth-First-Search
Binary-Search-Tree
Binary-Tree
LeetCode 938 note: prune with the BST order, going only right below low and only left above high, adding nodes inside the range
LeetCode 929: Unique Email Addresses
·2 mins
LeetCode
Easy
Array
Hash-Table
String
LeetCode 929 note: split at @, normalize only the local part (drop everything after +, remove dots), rejoin with the domain and collect in a set