LeetCode总结

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)算法的实现。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值