摘要:
小心这里是index triplets, 不是nums[i]数组元素的triplets, 所以3Sum那道题里面的跳过条件不用了 因为不关心每个index具体是什么,只关心个数,所以可以排序 阅读全文
posted @ 2017-12-20 10:36
apanda009
阅读(143)
评论(0)
推荐(0)
摘要:
Time Complexity will be O(n) because the "start" and "end" points will only move from left to right once. 阅读全文
posted @ 2017-12-20 06:24
apanda009
阅读(136)
评论(0)
推荐(0)
摘要:
我又想到了另一个idea,使用那个assumption可以达到O(1) 复杂度:首先判断isUp or not,仅以isUp为例, 假设A[x] 是最高点,则有:A[x] - A[i] = x - i. A[x] - A[j] = j - x由此可以解出 x = 1/ 2 * (A[j] - A[i 阅读全文
posted @ 2017-12-20 02:49
apanda009
阅读(161)
评论(0)
推荐(0)

浙公网安备 33010602011771号