leetcode ----167. Two Sum II - Input array is sorted
来源:互联网 发布:编程语言排行榜2017 7 编辑:程序博客网 时间:2024/05/27 00:40
int helper(int left,int right,int target,vector<int>&numbers) { while(left<=right) { int mid = (right+left)/2; if(numbers[mid]==target) { return mid; } if(numbers[mid]<target) { left = mid+1; } else right = mid-1; } return -1; } vector<int> twoSum(vector<int>& numbers, int target) { vector<int> res; for(int i=0;i<numbers.size();i++) { int flag = helper(i+1,numbers.size()-1,target-numbers[i],numbers); if(flag!=-1) { res.push_back(i+1); res.push_back(flag+1); break; } } return res; }
0 0
- Leetcode-167.Two Sum II - Input array is sorted
- [leetcode] 167. Two Sum II - Input array is sorted
- 【leetcode】167. Two Sum II - Input array is sorted
- 【LeetCode】167. Two Sum II - Input array is sorted
- [LeetCode OJ]167. Two Sum II - Input array is sorted
- [leetcode]167. Two Sum II - Input array is sorted
- leetcode-java-167. Two Sum II - Input array is sorted
- 【leetcode】167. Two Sum II - Input array is sorted
- LeetCode—167. Two Sum II - Input array is sorted
- [LeetCode]167. Two Sum II - Input array is sorted
- [LeetCode] 167. Two Sum II - Input array is sorted
- [leetcode] 167. Two Sum II - Input array is sorted
- LeetCode 167. Two Sum II - Input array is sorted
- LeetCode 167. Two Sum II - Input array is sorted
- leetcode ----167. Two Sum II - Input array is sorted
- leetcode 167. Two Sum II - Input array is sorted
- LeetCode 167. Two Sum II - Input array is sorted
- [Leetcode]167. Two Sum II - Input array is sorted
- 字符串变量数组--
- Spring常用注解
- 【QT】槽无法接收信号
- 数学符号读法大全
- Logistic回归
- leetcode ----167. Two Sum II - Input array is sorted
- Openwrt平台搭建(一)
- HTTP协议
- ETL利器Kettle实战应用解析系列一【Kettle使用介绍】
- 实战mysql集群搭建(二)-- 实现mysql数据库主从复制
- Window 查看硬盘信息,硬盘序列号,硬盘型号
- java 替换反斜杠 Unexpected internal error near index 1
- 有return的情况下try catch finally的执行顺序(最有说服力的总结)
- hibernate工作原理