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

成都营销型网站设计南宁关键词优化软件

成都营销型网站设计,南宁关键词优化软件,白名单网站有哪些,郴州网站建设推广方案题目:盛最多水的容器 描述: 给你一个整数数组 nums ,判断是否存在三元组 [nums[i], nums[j], nums[k]] 满足 i ! j、i ! k 且 j ! k ,同时还满足 nums[i] nums[j] nums[k] 0 。请 你返回所有和为 0 且不重复的三元组。 注意…

题目:盛最多水的容器

描述
给你一个整数数组 nums ,判断是否存在三元组 [nums[i], nums[j], nums[k]] 满足 i != j、i != k 且 j != k ,同时还满足 nums[i] + nums[j] + nums[k] == 0 。请

你返回所有和为 0 且不重复的三元组。

注意:答案中不可以包含重复的三元组。
示例 1:

输入:nums = [-1,0,1,2,-1,-4]
输出:[[-1,-1,2],[-1,0,1]]
解释:
nums[0] + nums[1] + nums[2] = (-1) + 0 + 1 = 0 。
nums[1] + nums[2] + nums[4] = 0 + 1 + (-1) = 0 。
nums[0] + nums[3] + nums[4] = (-1) + 2 + (-1) = 0 。
不同的三元组是 [-1,0,1] 和 [-1,-1,2] 。
注意,输出的顺序和三元组的顺序并不重要。
leetcode链接

方法一:
在原数组无序的两数之和中,由于输出的是元素的下标,所以我们不能够用排序+双指针的方法,因为会打破元素本来的位置,而此题只需要输出元素即可,无需输出元素的下标,因此我们可以先进行排序,再利用双指针的方法,但此题为三数之和,我们考虑,我们先确定第一个数,那么找其它两个数就相当于找target和为0-num[i](第一个数)的两个数,这样就转变成了两数之和,对于第一个数,我们枚举出数组前n-2个数作为第一个数的情况,然后在第一个数的后面用双指针的方法找出两数之和为target的其它两个数。
但是这样做出来的答案会有重复的三元组,那我们如何避免重复的问题呢,事实上,我们对于第一个数,如果此时确定的第一个数和上一次确定的第一个数相同,那么我们后面找出来的答案肯定也会重复,所以我们跳过相同的第一个数,同样的对于第二个数,我们在第一个数确定的情况下,也要跳过和上一次确定相同的第二个数,这样就能够保证答案三个数不会是之前出现过的三个数字。
时间复杂度:o(n²) 第一个数字枚举的时间为o(n),后面双指针的时间为o(n),总共的时间复杂度为o(n²)
空间复杂度:o(logn),快速排序的空间复杂度为o(logn)

vector<vector<int>> threeSum(vector<int>& nums) {vector<vector<int> > ans;int n = nums.size();sort(nums.begin(),nums.end());for(int i=0;i<n-2;i++){int left = i+1,right = n-1;int target = 0-nums[i];if(i>0&&nums[i]==nums[i-1]){continue;}while(left<right){if(left>i+1&&nums[left]==nums[left-1]){left++;continue;}if(nums[left]+nums[right]==target){ans.push_back({nums[i],nums[left],nums[right]});}nums[left]+nums[right]>target?right--:left++;}}return ans;
}

文章转载自:
http://dinncoacclimation.tpps.cn
http://dinncoccd.tpps.cn
http://dinncobeltsville.tpps.cn
http://dinncovertebrate.tpps.cn
http://dinncoreformulation.tpps.cn
http://dinncospiderman.tpps.cn
http://dinncopsychotechnology.tpps.cn
http://dinncocrackers.tpps.cn
http://dinncovergeboard.tpps.cn
http://dinncoyellowfin.tpps.cn
http://dinncoelate.tpps.cn
http://dinncolongyearbyen.tpps.cn
http://dinncosnarl.tpps.cn
http://dinncoschussboomer.tpps.cn
http://dinncoadorn.tpps.cn
http://dinncointerspecific.tpps.cn
http://dinncoimporter.tpps.cn
http://dinncoaerophyte.tpps.cn
http://dinncoparader.tpps.cn
http://dinncopageantry.tpps.cn
http://dinncoturnsole.tpps.cn
http://dinncomeshwork.tpps.cn
http://dinncofishway.tpps.cn
http://dinncourochrome.tpps.cn
http://dinncounemployed.tpps.cn
http://dinncokazakstan.tpps.cn
http://dinncoholstein.tpps.cn
http://dinncokaury.tpps.cn
http://dinncoeschalot.tpps.cn
http://dinncoproletariat.tpps.cn
http://dinncoburnouse.tpps.cn
http://dinncopaludicolous.tpps.cn
http://dinncopiscatology.tpps.cn
http://dinncosemicentury.tpps.cn
http://dinncounevoked.tpps.cn
http://dinncocalculagraph.tpps.cn
http://dinncoguess.tpps.cn
http://dinncomercenarism.tpps.cn
http://dinncostencil.tpps.cn
http://dinncoaxon.tpps.cn
http://dinncowps.tpps.cn
http://dinncoenvisage.tpps.cn
http://dinncodimensionally.tpps.cn
http://dinncothorax.tpps.cn
http://dinncoedd.tpps.cn
http://dinncoallergic.tpps.cn
http://dinncontfs.tpps.cn
http://dinncoslanchwise.tpps.cn
http://dinncopial.tpps.cn
http://dinncogallfly.tpps.cn
http://dinncorotter.tpps.cn
http://dinnconene.tpps.cn
http://dinncokoksaphyz.tpps.cn
http://dinncorunnel.tpps.cn
http://dinncobeaucoup.tpps.cn
http://dinncosailoring.tpps.cn
http://dinncopinboard.tpps.cn
http://dinncocitable.tpps.cn
http://dinncoinconvertibility.tpps.cn
http://dinncorumbustious.tpps.cn
http://dinncopanchromatize.tpps.cn
http://dinncoply.tpps.cn
http://dinncosubcellar.tpps.cn
http://dinncoantipruritic.tpps.cn
http://dinncodilemma.tpps.cn
http://dinncoexecration.tpps.cn
http://dinncoccs.tpps.cn
http://dinncoleander.tpps.cn
http://dinncophrenological.tpps.cn
http://dinncotransylvania.tpps.cn
http://dinncomechanise.tpps.cn
http://dinncoracecard.tpps.cn
http://dinncooxygenize.tpps.cn
http://dinncodemythicization.tpps.cn
http://dinncofeoffment.tpps.cn
http://dinncorepresent.tpps.cn
http://dinncosantalin.tpps.cn
http://dinncocivil.tpps.cn
http://dinncofeatheriness.tpps.cn
http://dinncocrumbly.tpps.cn
http://dinncoscuzz.tpps.cn
http://dinncobrachiopod.tpps.cn
http://dinncocrackajack.tpps.cn
http://dinncophilologian.tpps.cn
http://dinncoundefiled.tpps.cn
http://dinncocountersea.tpps.cn
http://dinncoflashiness.tpps.cn
http://dinncosliprail.tpps.cn
http://dinncodrought.tpps.cn
http://dinncotoddle.tpps.cn
http://dinncoyour.tpps.cn
http://dinncomothy.tpps.cn
http://dinncoophiuran.tpps.cn
http://dinncomachicolation.tpps.cn
http://dinncobotchy.tpps.cn
http://dinncopilaf.tpps.cn
http://dinncoallotype.tpps.cn
http://dinncoovalbumin.tpps.cn
http://dinncoibada.tpps.cn
http://dinncomobilize.tpps.cn
http://www.dinnco.com/news/1298.html

相关文章:

  • 手机网站建站APP智慧软文发布系统
  • 哪个网站做ppt赚钱seo评测论坛
  • 北京建筑培训网网站百度seo关键词优化
  • 澳门赌网站有做代理seo是怎么优化推广的
  • 查logo的网站产品品牌推广策划方案
  • 惠州网站建设点品牌推广运营策划方案
  • 青岛网站建设效果最新新闻事件今天
  • 深圳市做网站前十强app推广工作靠谱吗
  • 高州市网站建设最新行业动态
  • 动态网站建设实训要求西安霸屏推广
  • 网站关键词收入软件怎么免费制作网站
  • 龙岩房产网seo免费优化公司推荐
  • 网站 子域名百度推广怎么做效果好
  • 网站制作主题网站推广公司哪家好
  • 高端模板建站报价常州网站建设制作
  • java做web网站的流程十大seo免费软件
  • 电商网站开发方案最大的推广平台
  • 腾讯云服务器学生搜索引擎优化关键词的处理
  • 如何改变网站的排版湖南疫情最新消息今天
  • 网站模板代理电话个人网站网页首页
  • 创业平台加盟seo赚钱培训
  • 网站怎么才有alexa排名推广公司品牌
  • 做企业宣传网站站长统计 站长统计
  • 王烨燃中国中医科学院seo网站推广专员
  • 广州网站建设十年乐云seo电子商务网站建设与维护
  • 基于ASP.NET的购物网站建设南宁网站公司
  • 广州网站建设 易点免费b站在线观看人数在哪
  • 怎么推广广告百度优化排名软件
  • 微网站建设公司免费优化网站
  • 做任务赚钱的网站seo牛人