刷题(和复习)

08/05/2019

Category: Array

Problem #: 1. Two Sum: HashMap

15. 3Sum : Set one target and flow from left to right

16. 3Sum Closest : Pretty same as 3Sum but more easy

18. 4Sum  : Pretty same as 3Sum with one more exterior loop

08/06/2019

category: Array

26. Remove Duplicates from Sorted Array  using a fast and slow pointer Watch out for the index.

80. Remove Duplicates from Sorted Array II  : Same as the above one with one more flag to check if there's 3 duplicates

128. LOngest Consecutive Sequence:  set a target, from both its left and right side, find the longest consequtive sequence, withe the use of hashset. Once an element was checked, it should be removed to save time.

27. Remove Element  The same as 26, 80

283. MOve Zeroes  The same as above.

31. Next Permutation  3steps, a. From right to left find the first one doesn't in ascending order, called target. b. From right to left find the first one larger than target, switch them. c. from the first right one of index of target, reverse to the end.

36. Valid SudoKu  Using double loop and a HashSet, clearly add information of wether the particular number is in this row or  column or block. For example, if a number has already existed in this row, if another one 

also exists, it returns false.

猜你喜欢

转载自www.cnblogs.com/wentiliangkaihua/p/11302376.html