标签:width tar class str img amp else code sum
题目:
解答:
1 class Solution { 2 public: 3 vector<int> twoSum(vector<int>& numbers, int target) 4 { 5 int low = 0; 6 int high = numbers.size() - 1; 7 8 while (low < high) 9 { 10 int sum = numbers[low] + numbers[high]; 11 if (sum == target) 12 { 13 return {low + 1, high + 1}; 14 } 15 else if (sum < target) 16 { 17 ++low; 18 } 19 else 20 { 21 --high; 22 } 23 } 24 return {-1, -1}; 25 } 26 };
标签:width tar class str img amp else code sum
原文地址:https://www.cnblogs.com/ocpc/p/12827077.html