https://leetcode.com/problems/two-sum/
先排序,有序后枚举a,二分查找b,因为必然有解,直接找到就return。
class Solution {public: struct node { int num; int ord; }; static bool cmp(node a,node b) { return a.num& temp,int key) { while(l<=r) { int mid=(l+r)>>1; if(temp[mid].num==key) return mid; if(temp[mid].num>key) r=mid-1; if(temp[mid].num