1
class Solution {
2
public:
3
vector<int> twoSum(vector<int> &numbers, int target) {
4
int low = 0;
5
int high = numbers.size() - 1;
6
vector<int> ans;
7
while (low <= high) {
8
int sum = numbers[low] + numbers[high];
9

10
if (sum == target)
11
return vector<int>{low + 1, high + 1};
12

13
else if (sum > target)
14
high = high - 1;
15

16
else
17
low = low + 1;
18
}
19
return vector<int>{};
20
;
21
}
22
};

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0