当前位置:网站首页>6、双指针——递增数组两数之和与目标数相等
6、双指针——递增数组两数之和与目标数相等
2022-07-28 09:58:00 【[email protected]】
public int[] twoSum(int[] nums, int target) {
int low = 0, high = nums.length-1;
while(low < high){
int sum = nums[low] + nums[high];
if(sum < target) low++;
else if(sum >target) high--;
else return new int[] { nums[low], nums[high]};
}
return new int[0];
}
运行结果:
版权声明
本文为[[email protected]]所创,转载请带上原文链接,感谢
https://blog.csdn.net/zjj1910066023/article/details/124638590
边栏推荐
- vc链接静态库的时候要注意的问题
- Platofarm has made continuous progress, and has launched the official version and super primitive NFT successively
- Thinking and summary of technical personnel | R & D Efficiency
- 2021.07.13 我们是这样崩的
- Being on duty less than 8 hours a day and being dismissed? Tencent's former employees recovered 13million overtime pay, etc., and the court won a compensation of 90000 in the final judgment
- CloudCompare&PCL 匹配点采样一致性抑制
- Cloudcompare & PCL matching point sampling consistency suppression
- Voice chat app - how to standardize the development process?
- On July 13, 2021, we collapsed like this
- [learning notes] border and period
猜你喜欢

B2B e-commerce website scheme for building materials industry: enable the transformation and upgrading of building materials enterprises to achieve cost reduction and efficiency improvement

Why should I take the first-class constructor examination? How high is the gold content of the first-class Constructor Certificate?

13 probability distributions that must be understood in deep learning

广州地铁14号线新市墟站开建,白云区居民即将开启双线换乘模式!

语音聊天app——如何规范开发流程?

我用小程序容器让移动研发效率提升了5倍!

定了!就在7月30日!

Weekly report on July 27, 2022

剑指offer

Redis interview questions must be known and learned
随机推荐
2021.07.13 我们是这样崩的
Kubernetes
What are the highlights of B2B2C system? How to help jewelry enterprises build an omni channel multi merchant mall management system
Performance test of API gateway APIs IX in Google cloud T2a and T2D
Boss: there are too many systems in the company. Can we realize account interworking?
Introduction to timebasedrollingpolicy
SQL Server、MySQL主从搭建,EF Core读写分离代码实现
leetcode——旋转数组的最小数字
双指针技巧
Openatom openharmony sub forum, see you today at 14:00! Wonderful release of memorabilia attached
二维前缀和
ADVANCE.AI出海指南助力企业出海印尼,掌握东南亚市场半边天
基于docker安装MySQL
排序——快速排序(快慢指针实现)
软件设计师考前20问,注意啦!!
LIBCMTD.lib
(十)defer关键字
腾讯技术专家:解密亿级用户产品 微信、QQ、王者荣耀...全面上云实践!
On July 13, 2021, we collapsed like this
Redis设计规范