标签:size com return get 试题 offer tmp class i++
链接:https://leetcode-cn.com/problems/he-wei-sde-liang-ge-shu-zi-lcof/
class Solution {
public:
vector<int> twoSum(vector<int>& nums, int target) {
int n = nums.size() - 1;
int i, j, tmp;
while (nums[n] >= target) n--;
i = 0, j = n;
while (i < j) {
tmp = nums[i] + nums[j];
if (tmp == target) {
return vector<int>{nums[i], nums[j]};
} else if (tmp > target) j--;
else i++;
}
return vector<int>();
}
};
标签:size com return get 试题 offer tmp class i++
原文地址:https://www.cnblogs.com/clown9804/p/12462327.html