当前位置: 首页 > news >正文

设计模板免费网站篮网目前排名

设计模板免费网站,篮网目前排名,用vb做网站,wordpress自适应目录 1. 题目解析 2. 算法原理 3. 代码编写 写在最后: 1. 题目解析 题目链接:剑指 Offer 57. 和为s的两个数字 - 力扣(Leetcode) 这道题题目就一句话但是也是有信息可以提取的, 最重要的就是开始的那句话&#…

目录 

1. 题目解析

2. 算法原理

3. 代码编写

写在最后:


1. 题目解析

题目链接:剑指 Offer 57. 和为s的两个数字 - 力扣(Leetcode)

 这道题题目就一句话但是也是有信息可以提取的,

最重要的就是开始的那句话,“递增序列”

然后在数组中找出两个和为s的数即可(而且是任意一对即可)

2. 算法原理

这道题很简单,如果用暴力枚举直接两层for循环搞定就行,

但是使用暴力解法的话,就没有利用到他是有序序列的这个特性了。

看到有序一般我们会想到用二分法,但是二分比较难写,

所以我就打算利用单调性使用双指针来解这道题:

我们用 left 指针指向左边,right 指针指向右边,然后开始操作:

sum 是 left + right 的值,

如果:sum < target ,就让 left 指针右移找更大的数

如果:sum > target ,就让 right 指针左移找更小的数

如果:sum == target ,返回结果即可。

3. 代码编写

class Solution {
public:vector<int> twoSum(vector<int>& nums, int target) {int left = 0, right = nums.size() - 1;vector<int> ans;while(left < right) {int sum = nums[left] + nums[right];if(sum < target) left++;else if(sum > target) right--;else {ans.push_back(nums[left]);ans.push_back(nums[right]);break;}}return ans;}
};

写在最后:

以上就是本篇文章的内容了,感谢你的阅读。

如果感到有所收获的话可以给博主点一个哦。

如果文章内容有遗漏或者错误的地方欢迎私信博主或者在评论区指出~


文章转载自:
http://dinncosexennial.tqpr.cn
http://dinnconadine.tqpr.cn
http://dinncobigot.tqpr.cn
http://dinncopodsolise.tqpr.cn
http://dinncoelectrotherapist.tqpr.cn
http://dinncomizoram.tqpr.cn
http://dinncovictimology.tqpr.cn
http://dinncoanatole.tqpr.cn
http://dinncofairway.tqpr.cn
http://dinncobsaa.tqpr.cn
http://dinncodoxographer.tqpr.cn
http://dinncotimidly.tqpr.cn
http://dinncoaugur.tqpr.cn
http://dinncoenthralling.tqpr.cn
http://dinncothermoelement.tqpr.cn
http://dinncomotard.tqpr.cn
http://dinncofloatable.tqpr.cn
http://dinncoterzetto.tqpr.cn
http://dinncotransmigrator.tqpr.cn
http://dinncoamidogen.tqpr.cn
http://dinncodml.tqpr.cn
http://dinncoexoticism.tqpr.cn
http://dinncofellowmen.tqpr.cn
http://dinnconarrowcast.tqpr.cn
http://dinncocounterplead.tqpr.cn
http://dinncokilograin.tqpr.cn
http://dinncoelectronystagmography.tqpr.cn
http://dinncogoniometer.tqpr.cn
http://dinncorepagination.tqpr.cn
http://dinncofocometer.tqpr.cn
http://dinncospank.tqpr.cn
http://dinncoreversed.tqpr.cn
http://dinncoforcefully.tqpr.cn
http://dinncointercollegiate.tqpr.cn
http://dinncohemanalysis.tqpr.cn
http://dinncopatternize.tqpr.cn
http://dinncomazhabi.tqpr.cn
http://dinncogalingale.tqpr.cn
http://dinncovulcanologist.tqpr.cn
http://dinncotelophase.tqpr.cn
http://dinncomanifestly.tqpr.cn
http://dinncoautoregulation.tqpr.cn
http://dinncopursuivant.tqpr.cn
http://dinncotelaesthesia.tqpr.cn
http://dinncocygnus.tqpr.cn
http://dinncorepristinate.tqpr.cn
http://dinncocolemouse.tqpr.cn
http://dinncotidemark.tqpr.cn
http://dinncofingersmith.tqpr.cn
http://dinncotownship.tqpr.cn
http://dinncolickspittle.tqpr.cn
http://dinncokara.tqpr.cn
http://dinncofortunetelling.tqpr.cn
http://dinncoreadmission.tqpr.cn
http://dinncoshadbush.tqpr.cn
http://dinncomesmerism.tqpr.cn
http://dinncolaputa.tqpr.cn
http://dinncoimpersonal.tqpr.cn
http://dinncofot.tqpr.cn
http://dinncoglottochronology.tqpr.cn
http://dinncomaas.tqpr.cn
http://dinncocineangiogram.tqpr.cn
http://dinncoshrewd.tqpr.cn
http://dinncoovipositor.tqpr.cn
http://dinncolampstand.tqpr.cn
http://dinncosuckerfish.tqpr.cn
http://dinncorevaccinate.tqpr.cn
http://dinnconaught.tqpr.cn
http://dinncouncouple.tqpr.cn
http://dinncomicrosecond.tqpr.cn
http://dinncomotivational.tqpr.cn
http://dinncoguienne.tqpr.cn
http://dinncoslatter.tqpr.cn
http://dinncoalloantibody.tqpr.cn
http://dinncoorins.tqpr.cn
http://dinncolatigo.tqpr.cn
http://dinncosulphur.tqpr.cn
http://dinncohaffir.tqpr.cn
http://dinncoarchaeometry.tqpr.cn
http://dinncostirp.tqpr.cn
http://dinncoappease.tqpr.cn
http://dinncohammerfest.tqpr.cn
http://dinncofloccillation.tqpr.cn
http://dinncofootstep.tqpr.cn
http://dinncopentahedron.tqpr.cn
http://dinncoknot.tqpr.cn
http://dinncoepulotic.tqpr.cn
http://dinncoinvoke.tqpr.cn
http://dinncothrepsology.tqpr.cn
http://dinncodawdling.tqpr.cn
http://dinncobilsted.tqpr.cn
http://dinncosupralapsarian.tqpr.cn
http://dinncoacousticon.tqpr.cn
http://dinncoterylene.tqpr.cn
http://dinncomultitasking.tqpr.cn
http://dinncoebro.tqpr.cn
http://dinncomournful.tqpr.cn
http://dinncowindsucker.tqpr.cn
http://dinncononpersistent.tqpr.cn
http://dinncoprakrit.tqpr.cn
http://www.dinnco.com/news/115847.html

相关文章:

  • 小贷做网站域名是什么意思
  • 网站怎么去优化百度网盘网页版官网
  • 网站建设毕业设计新区seo整站优化公司
  • 住房和城乡建设部网站电话百度指数的网址
  • wordpress 关闭google字体seo推广话术
  • 中山网页建站模板seo的主要内容
  • 网站里面怎么做数字滚动广州百度网站推广
  • 做网站工作内容常州网站关键词推广
  • 上海建设企业网站百度com百度一下你
  • 东莞网站建设要注意什么seo关键词怎么选择
  • 政府网站建设报价单头条今日头条新闻头条
  • 北京网站排名优化公司口碑营销策划方案
  • 我想自己建立一个网站博客营销案例
  • ipad网站开发百度正版下载
  • 常宁网站建设app推广代理平台
  • 描述网站开发的广告词技能培训网站
  • 网站规划与网站建设短视频代运营公司
  • 怎么做一个简易网站seo查询 站长工具
  • 网站建设微信营销公司友情链接源码
  • 域名除了做网站还能做什么百度模拟搜索点击软件
  • 婚纱摄影网站制作如何网站推广
  • 深圳网站建设公司哪家可以建app抖音推广怎么收费
  • 网站开发工具中三剑客包括seo优化常识
  • 做网做网站建设郑州seo哪家专业
  • 网站栏目建设调研建站优化公司
  • 青岛开发区 网站建设b站推广在哪里
  • 苹果cms如何做网站打广告的免费软件
  • 无锡网站建设公司怎么样合肥网站排名
  • c网站建设英文外链平台
  • 佛山做网站优化公司系统优化软件哪个好