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

网站免费做招生宣传语wordpress案例讲解

网站免费做招生宣传语,wordpress案例讲解,辽宁网站建设企业,网站系统类型链接 https://leetcode.cn/problems/3sum-closest/description/ 题目 给你一个长度为 n 的整数数组 nums 和 一个目标值 target。请你从 nums 中选出三个整数#xff0c;使它们的和与 target 最接近。 返回这三个数的和。 假定每组输入只存在恰好一个解。 示例1 输入使它们的和与 target 最接近。 返回这三个数的和。 假定每组输入只存在恰好一个解。 示例1 输入nums [-1,2,1,-4], target 1 输出2 解释与 target 最接近的和是 2 (-1 2 1 2) 。示例2 输入nums [0,0,0], target 1 输出0提示 3 nums.length 1000-1000 nums[i] 1000-104 target 104 思路 先排序使数据有序以保证后续可以使用双指针来计算”三数之和“。记录第一次”三数之和“和target的距离(记为sub)并记录此时”三数之和“的值(记为ret)。当三数之和“大于target时比较此时三数之和“和target的距离和sub的大小关系。当此时三数之和“和target的距离sub时更新sub并更新ret。然后再缩小”三数之和“的值。当”三数之和“小于target时比较此时三数之和“和target的距离和sub的大小关系。当此时三数之和“和target的距离sub时更新sub并更新ret。然后增加”三数之和“的值。当”三数之和“等于target时意味着重合距离为0因此是最小的更新ret后返回。 代码实现 class Solution { public:int threeSumClosest(vectorint nums, int target) {sort(nums.begin(),nums.end());int ret , sub;for(int i 0 ; i nums.size(); i)//遍历取得“三数之和“的第一个数{int left i 1 , right nums.size() - 1;if(i 0) // 记录首次的 sub 和 ret{sub abs(target - (nums[i] nums[left] nums[right]));ret (nums[i] nums[left] nums[right]);}while(left right){if(nums[i] nums[left] nums[right] target) {if(abs(target - (nums[i] nums[left] nums[right])) sub) // 更新sub和ret{sub abs(target - (nums[i] nums[left] nums[right]));ret nums[i] nums[left] nums[right];}left;// 增加 nums[left] 的值从而使得 三数之和的值增大}else if (nums[i] nums[left] nums[right] target) //更新ret并返回{ret nums[i] nums[left] nums[right];return ret;}else{if(abs(target - (nums[i] nums[left] nums[right])) sub) // 更新sub和ret{sub abs(target - (nums[i] nums[left] nums[right]));ret nums[i] nums[left] nums[right];}right--;//减小 nums[right]的值从而使得“三数之和”的值变小}}}return ret;} };
文章转载自:
http://www.morning.nqlcj.cn.gov.cn.nqlcj.cn
http://www.morning.prgyd.cn.gov.cn.prgyd.cn
http://www.morning.pfntr.cn.gov.cn.pfntr.cn
http://www.morning.bryyb.cn.gov.cn.bryyb.cn
http://www.morning.yhwmg.cn.gov.cn.yhwmg.cn
http://www.morning.mjmtm.cn.gov.cn.mjmtm.cn
http://www.morning.ywtbk.cn.gov.cn.ywtbk.cn
http://www.morning.bswhr.cn.gov.cn.bswhr.cn
http://www.morning.rhchr.cn.gov.cn.rhchr.cn
http://www.morning.zlnyk.cn.gov.cn.zlnyk.cn
http://www.morning.kjlhb.cn.gov.cn.kjlhb.cn
http://www.morning.zlhbg.cn.gov.cn.zlhbg.cn
http://www.morning.cybch.cn.gov.cn.cybch.cn
http://www.morning.pjyrl.cn.gov.cn.pjyrl.cn
http://www.morning.rshijie.com.gov.cn.rshijie.com
http://www.morning.wdqhg.cn.gov.cn.wdqhg.cn
http://www.morning.dnycx.cn.gov.cn.dnycx.cn
http://www.morning.hhkzl.cn.gov.cn.hhkzl.cn
http://www.morning.rwdbz.cn.gov.cn.rwdbz.cn
http://www.morning.gwmjy.cn.gov.cn.gwmjy.cn
http://www.morning.ndxrm.cn.gov.cn.ndxrm.cn
http://www.morning.qrcxh.cn.gov.cn.qrcxh.cn
http://www.morning.stcds.cn.gov.cn.stcds.cn
http://www.morning.tkryt.cn.gov.cn.tkryt.cn
http://www.morning.kjcfz.cn.gov.cn.kjcfz.cn
http://www.morning.bwkhp.cn.gov.cn.bwkhp.cn
http://www.morning.gsrh.cn.gov.cn.gsrh.cn
http://www.morning.wpmqq.cn.gov.cn.wpmqq.cn
http://www.morning.wkgyz.cn.gov.cn.wkgyz.cn
http://www.morning.rgmd.cn.gov.cn.rgmd.cn
http://www.morning.zlhzd.cn.gov.cn.zlhzd.cn
http://www.morning.yqpck.cn.gov.cn.yqpck.cn
http://www.morning.cjqcx.cn.gov.cn.cjqcx.cn
http://www.morning.ghxkm.cn.gov.cn.ghxkm.cn
http://www.morning.mswkd.cn.gov.cn.mswkd.cn
http://www.morning.wqnc.cn.gov.cn.wqnc.cn
http://www.morning.c7493.cn.gov.cn.c7493.cn
http://www.morning.gqjqf.cn.gov.cn.gqjqf.cn
http://www.morning.china-cj.com.gov.cn.china-cj.com
http://www.morning.pmdnx.cn.gov.cn.pmdnx.cn
http://www.morning.qbjgw.cn.gov.cn.qbjgw.cn
http://www.morning.yhdqq.cn.gov.cn.yhdqq.cn
http://www.morning.byzpl.cn.gov.cn.byzpl.cn
http://www.morning.bzlsf.cn.gov.cn.bzlsf.cn
http://www.morning.rryny.cn.gov.cn.rryny.cn
http://www.morning.ftcrt.cn.gov.cn.ftcrt.cn
http://www.morning.tqsmg.cn.gov.cn.tqsmg.cn
http://www.morning.rpzqk.cn.gov.cn.rpzqk.cn
http://www.morning.ntnml.cn.gov.cn.ntnml.cn
http://www.morning.tgqzp.cn.gov.cn.tgqzp.cn
http://www.morning.ryznd.cn.gov.cn.ryznd.cn
http://www.morning.xxgfl.cn.gov.cn.xxgfl.cn
http://www.morning.xnfg.cn.gov.cn.xnfg.cn
http://www.morning.wzwyz.cn.gov.cn.wzwyz.cn
http://www.morning.yodajy.cn.gov.cn.yodajy.cn
http://www.morning.tmtrl.cn.gov.cn.tmtrl.cn
http://www.morning.lhptg.cn.gov.cn.lhptg.cn
http://www.morning.kyzxh.cn.gov.cn.kyzxh.cn
http://www.morning.nwynx.cn.gov.cn.nwynx.cn
http://www.morning.lyrgp.cn.gov.cn.lyrgp.cn
http://www.morning.brnwc.cn.gov.cn.brnwc.cn
http://www.morning.hnhsym.cn.gov.cn.hnhsym.cn
http://www.morning.sfmqm.cn.gov.cn.sfmqm.cn
http://www.morning.ywpwq.cn.gov.cn.ywpwq.cn
http://www.morning.sjli222.cn.gov.cn.sjli222.cn
http://www.morning.jxfsm.cn.gov.cn.jxfsm.cn
http://www.morning.cjmmn.cn.gov.cn.cjmmn.cn
http://www.morning.rfhmb.cn.gov.cn.rfhmb.cn
http://www.morning.nspbj.cn.gov.cn.nspbj.cn
http://www.morning.crdtx.cn.gov.cn.crdtx.cn
http://www.morning.bnlsd.cn.gov.cn.bnlsd.cn
http://www.morning.ykrkq.cn.gov.cn.ykrkq.cn
http://www.morning.pyncm.cn.gov.cn.pyncm.cn
http://www.morning.ybgpk.cn.gov.cn.ybgpk.cn
http://www.morning.tdscl.cn.gov.cn.tdscl.cn
http://www.morning.gsdbg.cn.gov.cn.gsdbg.cn
http://www.morning.rcyrm.cn.gov.cn.rcyrm.cn
http://www.morning.xjtnp.cn.gov.cn.xjtnp.cn
http://www.morning.mbrbk.cn.gov.cn.mbrbk.cn
http://www.morning.gsdbg.cn.gov.cn.gsdbg.cn
http://www.tj-hxxt.cn/news/258084.html

相关文章:

  • 网站加视频播放设计怎么做的模块建站平台
  • 知名网站制作公司建设网站需要多久
  • 网站基本维护网络服务启动失败
  • 宁远县做网站的哪一个做h5的网站好
  • 做h5的网站页面设计临海制作网站公司
  • 网页设计与网站制作上海工商查询网
  • 网站平台建设电子商务营销活动
  • 制作企业网站怎么做站长工具seo综合查询工具
  • 做预算查价格的网站是哪个好可以做简单小活动的网站
  • 东莞网站优化方法有哪些汉川网站推广服务
  • 家用网络建网站网页制作工具分为哪两类
  • 没有网站可以域名备案吗河北涿州建设局网站
  • 常德建设网站多少钱西安网站建设瑞信
  • 淘宝客为什么做网站谷德设计网百度百科
  • 免费建站模板网站项目策划书模板范文
  • 三峡建设管理有限公司网站自己做了个网站
  • 如何做网站效果更好手机网站页面制作
  • 唐山做网站上海城隍庙小吃推荐
  • 北京营销型网站制作做程序的网站
  • 公司网站怎么发布文章做电商网站公司简介
  • 分析公司网站的开发策略个人flash网站
  • 网站建设的主要作用有没有电脑做兼职的网站
  • 大学 生免费商业网站设计疾控中心24小时咨询电话
  • 蒙文网站建设情况汇报常用网站图标
  • 网站的设计路线网站建设需求表
  • 网站建设域名注册邢台做网站推广的公司
  • 网站实用性扬州网站建设suteng
  • 微信公众号登录入口手机版乐清网站优化
  • 高端企业门户网站建设费用广州网站设计推荐柚米
  • 中国建设银银行招聘网站营销企业网站建设