Skip to main content

array

Easy

NumberNote
9. Palindrome Numbercheck case related to 0 and smaller 10, find reverted_number - multiply 10 and 10 and 10 ... but need to compare only half (for odd or even, handle the return)
26. Remove Duplicates from Sorted Arraystarting from k=1 and check curr nums[i] with previous nums[k]
27. Remove Elementnums[count] and nums[i]
118. Pascal's Triangle2 loops, 2nd for's index starts from 1
121. Best Time to Buy and Sell StockminPrice and maxProfit, find the profit for each
169. Majority Elementcount and balance the appearance to at least 0, change to new number once they're back
217. Contains Duplicatesorting, check i-1 vs i or using set
242. Valid Anagramhasmap with get, how to check character in s has the same frequency to t (different order)
303. Range Sum Query - Immutableprefix
448. Find All Numbers Disappeared in an Arraynegate value for existing number, positive value is the missing one
605. Can Place Flowerstop solution, count consecutive empty (you know, we need 3 5 7) and check the empty is larger than 0, check the edge case (probably first and last element)
724. Find Pivot Indexfind sum_left and sum_right

Medium

NumberNote
11. Container With Most Watertwo pointer, left right, check min height, find max space, increase or decrease when which one is smaller
15. 3Sumsort, fix each + 2 pointer, check two consecutive in fix and check two consecutive in pointer (yes, increase left)
36. Valid Sudoku
53. Maximum Subarray
56. Merge Intervals
57. Insert Interval
75. Sort Colors
122. Best Time to Buy and Sell Stock II
128. Longest Consecutive Sequence
238. Product of Array Except Self
347. Top K Frequent Elements