1. 3 Sum, 3Sum Closest, 4Sum
Typical k-sum problems, time complexity should be O(n^(k-1))
2. binary search结束后,left是比target大的最小数,如果没有比target大的数,则left=A.length
right是比target小的最大数,如果没有比target小的数,那么right = -1
这里的binary search 是:
while(left<=right){
if...left=mid+1;
if...right=mid-1;
}
这种形式的
3. 在用递归处理一维或二维数组时,递归中最好不要循环处理数组元素了,而是focus在当前元素上。
4. 算法优化的方法总结:二分法,hashtable,bit manipulation, dynamic programming, two pointer实现的O(n)解法
to be continue......
todo:
1. Impelment strStr() 的KMP算法,和另一个O(n)算法的实现。