3 Longest Substring without repeating characters
- Hash table may record past result!!
- left = Math.max(left, map.get(char[right]));
10 Regular Expression Matching
- Iterative (DP)
- Recursive
29 Divide Two Integer
- pos, neg
- dividend < divisor, return 0
- use long to deal with over flow
- recursively find result, sum += sum, multiple += multiple
30. Substring with Concatenation of All Words
- Two pointer + hash table + sliding window
- Longest Valid Parentheses
- method 1: Stack, greedy
- method 2: DP
37 Sudoku Solver
- DFS, backtracking
- Only need to check the position of new added number is valid or not
- Pow(x, n)
- x = 0, n = 0, n < 0, n % 2
- n OverFlow!!!
218 The Skyline Problem
- Sort + PQ
168 Excel Sheet Column Title
- Shift -1 EACH TIME to get base 26
- 52 = AZ = (A' + 1) * 26 + (Z' + 1) * 1
215 Kth Largest Element in an Array
- Mind the partition fiction.
-
- nums[right] <= pivot)
- return helper(nums, left + 1, r, k);
- nums[right] <= pivot)
140 Word Break II
- Map<String, List<String>> dp save results
283 Moving zeros
- Do not focus on doing swap.
- Simply replace number!
57 Insert Interval
- mark down the insert position.
60 Permutation sequence
- factorial, remainder, used[]
68 Text Justification
- Last line should be left-justified.
- remainder spaces will be given to the first several space.
85 Maximal Rectangle
- Method 1. Utilize maximal rectangle in histogram
- Method 2. DP[], left[], right[], height[]
87 Scramble String
- recursion + cache
89 Gray Code
- Find the law!
93 Parse IP Address
- if(s.length()>3 || s.length()==0 || (s.charAt(0)=='0' && s.length()>1) || Integer.parseInt(s)>255)
95 Unique Binary Search Tree II
- DP for each level
- Build right Tree with offset.
97 Interleaving String
- Cache + Recursion
99 Recover Binary Search Tree
- Inorder Traversal to find the invalid element
115 Distinct Subsequences
- dp
125 Word Ladder II
- bfs to build neighbors and distance map
- dos find the result.
132 Palindrome Partitioning II
- dp
- odd length and even length palindrome, spread from the center.