当前位置:网站首页>剑指 Offer 57. 和为s的两个数字
剑指 Offer 57. 和为s的两个数字
2022-07-16 18:25:00 【anieoo】
solution:
双指针
class Solution {
public:
vector<int> twoSum(vector<int>& nums, int target) {
for(int i = 0,j = nums.size() - 1;i < j;) {
if(nums[i] + nums[j] > target) j--;
else if(nums[i] + nums[j] < target) i++;
else return {nums[i], nums[j]};
}
return {};
}
};
边栏推荐
- Equity structure design of start-up companies (cases)
- Flutter 绘制非常有趣的贝塞尔曲线动画
- Multipartfile to Base64
- Installation and deployment series (I) -- docker compose installation of redis cluster cluster
- The first ide overlord in the universe, replaced...
- 顺丰同城测试开发一面 49min答案
- 每日刷题记录 (二十五)
- Trickery applet (baby, I'm the biggest fool in the world x) code
- Code that programmers can't understand
- [untitled]
猜你喜欢

Tableau JDBC connection graphdb
![(manual) [sqli labs48, 49] order by injection, blind injection, get injection](/img/72/d3e46a820796a48b458cd2d0a18f8f.png)
(manual) [sqli labs48, 49] order by injection, blind injection, get injection

高数下|二重积分的概念及性质|高数叔|手写笔记

有点东西,竟然把VSCode玩成了IDEA的效果

Research on driverless dynamic obstacle avoidance strategy | robot dynamic obstacle avoidance strategy

Applet page navigation

Add, delete, check and modify the MySQL Learning Notes database (Advanced)

宇宙第一 IDE 霸主,换人了。。。

开口就要20k的软件测试工程师需要掌握哪些技能?有这些技能我敢要更高~

Error: cannot read properties of undefined (reading 'foreach')
随机推荐
I read the concept of time
嵌入式开发:加速固件开发的7个技巧
putchar()
How to create Dutch auction smart contract
Why should V-for add key
What skills do software test engineers need to master if they need to speak 20K? I dare to be higher with these skills~
记住这几点就能快速的去找到bug
Apache log related
1.解决com.mysql.jdbc.PacketTooBigException: Packet for query is too large
sentinel
【缓存】一种新的缓存 Caffeine Cach 介绍
R语言使用vtreat包的designTreatmentsC函数构建数据处理计划(treatment plan)、使用vtreat包进行数据准备
你猜不到的代码
Alibaba cloud video on demand
Scrcpy projection
Applet page navigation
面试问题五
开口就要20k的软件测试工程师需要掌握哪些技能?有这些技能我敢要更高~
1. Reptile overview
Code that programmers can't understand