Leetcode 167. Two Sum II - Input array is sorted
来源:互联网 发布:c语言调用终端命令 编辑:程序博客网 时间:2024/05/17 23:01
/** * Two-pointer approach. * pointer low starts from 0, pointer high starts from length-1 * if nums[low]+nums[high] == target return low and high * else if nums[low]+nums[high] > target means we need a samller number, move high forward * else nums[low]+nums[high] > target means we need a bigger number, move low backward */ public class Solution { public int[] twoSum(int[] numbers, int target) { int low = 0, high = numbers.length-1; while (low < high) { if (numbers[low]+numbers[high] == target) return new int[] {low+1, high+1}; else if (numbers[low]+numbers[high] < target) low++; else high--; } return new int[] {}; }}
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
- CentOS7防火墙管理firewalld
- 数据结构--字符串匹配
- 数字信号处理
- MyBatis中selectbyexample与selectbyexampleBlobs
- win7安装ubuntu后,双系统时间不一致
- Leetcode 167. Two Sum II - Input array is sorted
- 由于换了eclipse开发工具,从而装了高本版jdk导致的问题
- 多账户免登录的git客户端管理
- Oracle添加注释
- Spring 学习之旅(五) 持久层的配置,注册实现以及项目重构
- Apache/Tomcat/JBOSS/Nginx区别
- 调试makefile变量
- Android+PHP服务器和客户端真机实验
- Oracle修改操作