Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public:
- vector<int> twoSum(vector<int>& numbers, int target) {
- for(int i=1;i<numbers.size();i++){
- int d=target-numbers[i];
- int l=lower_bound(numbers.begin(),numbers.begin()+i-1,d)-numbers.begin();
- if(l<numbers.size() && numbers[l]==d)
- return{l+1,i+1};
- }
- return {-1,-1};
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement