m*****n 发帖数: 5245 | 1 ☆─────────────────────────────────────☆
Ryter (Ryter) 于 (Sat Sep 12 14:35:53 2009, 美东) 提到:
Given a sorted integer array and a number, find all the pairs that sum up to
the number.
这个很简单,但现在多了一个条件
What if the array is sorted by absolute value, for example {1, -2, 4, -9},
find the answer in O(N).
这样有什么好的思路么?
☆─────────────────────────────────────☆
zhimage (common) 于 (Sat Sep 12 15:03:31 2009, 美东) 提到:
A general solution regardless of whether the array is sorted or not.
Assume the original |
|