-
Notifications
You must be signed in to change notification settings - Fork 0
0 Overview
Tim_Gao edited this page Sep 17, 2016
·
30 revisions
-
Bit manipulation
Basically the idea is examining the bits of each number- Majority Number
- Single Number II and Single Number III
-
HashMap + two pointers
To process substring problems. Use HashMap to store characters information and use two pointers to update the HashMap.- Longest Substring with at most two distinct characters
- Longest substring without repeating characters;
- Minimum window substring
- Longest Substring with At Most K Distinct Characters
-
Stack
- Largest Rectangle in histogram
- Largest valid parentheses
- Trapping rain water
Store index in stack
-
compute modulo
Basically use (n-1)%base to deal with edge cases- Excel Sheet Column Title
- permutation sequence, given a number n, return the nth permutation sequence
-
Divide and Conquer
- Different Ways to Add Parentheses (this one is good)
Basically divide the input into two by an operator and then fed the substrings to the same function
a+c*c+d*e --> (a) + (c*c+d*e) or (a+c) * (c+d*e)...
- Different Ways to Add Parentheses (this one is good)
-
Memorized Dynamic Programming
Basically take advantage of the results computed before. (what kind of DP is not suitable for memorized DP)- Guess Number Higher or Lower II
- IntegerBreak
-
Combination sum like algorithm
- Subset
-
Memorized DFS
- Longest increasing path in a matrix
This is pretty good. One thing that worth thinking is in what situation we can use memorized DFS.
- Longest increasing path in a matrix
-
MergeSort plus counting
- count of range sum
Another way to merge two subarrays. Instead of using two pointers, you can iterate through one of them. Another important thing is how to calculate the number of subarrays whose sum is in[lower, upper]. You don't have to start from the very beginning to count for each i in the first array. - Count of smaller numbers after self
pay attention to the case where nums[p1] == nums[p2], which one goes to the result array first
- count of range sum
-
List all possible solution
- Create Maximum Number
The most difficult part is how to merge two subarrays to create the maximum number (I made mistakes at this step every time)
- Create Maximum Number
-
Stack + HashMap
The idea is create a hash map storing all the characters and then use a stack to get a max or min order. I feel like that Stack is extremely good for ordering things- Remove Duplicate Letters
- Create Maximum Number
-
plain two pointers
- Trapping rain water nice idea