Easy
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
LeetCode 671: Second Minimum Node In a Binary Tree
·2 mins
LeetCode
Easy
Tree
Depth-First-Search
Binary-Tree
LeetCode 671 note: the root is the minimum; the second minimum is the smallest value larger than the root, and only subtrees equal to the root need searching
LeetCode 661: Image Smoother
·2 mins
LeetCode
Easy
Array
Matrix
LeetCode 661 note: each cell becomes the floored average of the existing cells in its 3 × 3 neighborhood, written into a new matrix
LeetCode 657: Robot Return to Origin
·1 min
LeetCode
Easy
String
Simulation
LeetCode 657 note: returning to the origin means as many U as D and as many L as R
LeetCode 653: Two Sum IV - Input is a BST
·2 mins
LeetCode
Easy
Hash-Table
Two-Pointers
Tree
Depth-First-Search
LeetCode 653 note: traverse while keeping a set of seen values; finding k - val in it means a pair exists
LeetCode 645: Set Mismatch
·2 mins
LeetCode
Easy
Array
Hash-Table
Bit-Manipulation
Sorting
LeetCode 645 note: use sums: missing = sum of 1..n - sum of the set, duplicate = array sum - sum of the set
LeetCode 637: Average of Levels in Binary Tree
·1 min
LeetCode
Easy
Tree
Depth-First-Search
Breadth-First-Search
Binary-Tree
LeetCode 637 note: level-order traversal, dividing each level’s sum by its count
LeetCode 628: Maximum Product of Three Numbers
·1 min
LeetCode
Easy
Array
Math
Sorting
LeetCode 628 note: after sorting there are only two candidates: the three largest, or the two smallest (negatives) times the largest
LeetCode 605: Can Place Flowers
·2 mins
LeetCode
Easy
Array
Greedy
LeetCode 605 note: scan left to right and plant in any empty plot whose neighbors are empty; a new flower blocks the next plot, so actually update the array
LeetCode 599: Minimum Index Sum of Two Lists
·2 mins
LeetCode
Easy
Array
Hash-Table
String
LeetCode 599 note: map list1’s strings to indices, sum both indices while scanning list2, and keep every string with the minimum sum