十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
你可以假设每个输入刚好只有一个答案
给定数组为 [2,7,11,15]
,target = 9
返回 [1,2]
1 vector twoSum(vector &nums, int target) {
2 // write your code here 3 vector result;
4 int low=0;
5 int high=nums.size()-1;
6 while(lowtarget){
8 high--;
9 }
10 else if(nums[low]+nums[high]