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

客户关系管理系统流程图seo机构

客户关系管理系统流程图,seo机构,网站开发建设准备工作,外贸网站建设软件一、题目解析 分析这个题目不难得出一个容积公式 二、算法原理 解法一:暴力枚举(超时) 套用上述的容积公式,使用两个for循环来枚举出所有可能的情况,再挑出最大值即可,但是这种写法会超时,导致…

一、题目解析

 

分析这个题目不难得出一个容积公式

 

二、算法原理

解法一:暴力枚举(超时)

套用上述的容积公式,使用两个for循环来枚举出所有可能的情况,再挑出最大值即可,但是这种写法会超时,导致不通过。时间复杂度是O(n^2)

class Solution {
public:int maxArea(vector<int>& height) {int n = height.size();int ret = 0;    for (int i = 0; i < n; i++) {for (int j = i + 1; j < n; j++) {ret = max(ret, min(height[i], height[j]) * (j - i));}}return ret;}
};

可以自己去尝试一下。 

解法二:双指针 

设两个指针left,right分别为这个容器的左边界和右边界,根据容积公式可得

v = min( height[right], height[left]) * (right - left)

从题目中的测试用例中选取一段进行分析如下:

所以我们可以得出结论用较小的数向内枚举的话容积肯定是在减小的,所以较小的数我们就可以不用向后枚举了直接跳过,用较大的数向后枚举就行。 

最后选出容积最大值就行了。 时间复杂度是O(n)。

三、代码编写

class Solution {
public:int maxArea(vector<int>& height) {int left = 0, right = height.size() - 1, ret = 0;while(left < right){int v = min(height[left],height[right]) * (right - left);ret = max(ret, v);if(height[left] < height[right]){left++;}else {right--;}}return ret;}
};

文章转载自:
http://farm.sqxr.cn
http://forwearied.sqxr.cn
http://greeneland.sqxr.cn
http://booby.sqxr.cn
http://semidemisemiquaver.sqxr.cn
http://illy.sqxr.cn
http://encoop.sqxr.cn
http://automatise.sqxr.cn
http://urethroscopy.sqxr.cn
http://gls.sqxr.cn
http://equitant.sqxr.cn
http://nm.sqxr.cn
http://portend.sqxr.cn
http://cystamine.sqxr.cn
http://apiarian.sqxr.cn
http://wucai.sqxr.cn
http://indigo.sqxr.cn
http://hobbyhorse.sqxr.cn
http://geocentrism.sqxr.cn
http://massicot.sqxr.cn
http://hernial.sqxr.cn
http://mandrill.sqxr.cn
http://ruddy.sqxr.cn
http://flyby.sqxr.cn
http://rebellion.sqxr.cn
http://antoninianus.sqxr.cn
http://florescent.sqxr.cn
http://balloonfish.sqxr.cn
http://klaxon.sqxr.cn
http://flagella.sqxr.cn
http://undope.sqxr.cn
http://paster.sqxr.cn
http://dysenteric.sqxr.cn
http://geometrist.sqxr.cn
http://deciare.sqxr.cn
http://dovap.sqxr.cn
http://cathead.sqxr.cn
http://presbyopia.sqxr.cn
http://liberative.sqxr.cn
http://mohock.sqxr.cn
http://ovonics.sqxr.cn
http://affrontive.sqxr.cn
http://goldarn.sqxr.cn
http://aisled.sqxr.cn
http://restauratrice.sqxr.cn
http://plus.sqxr.cn
http://metaphrase.sqxr.cn
http://construct.sqxr.cn
http://lankiness.sqxr.cn
http://secretarial.sqxr.cn
http://draffy.sqxr.cn
http://araneid.sqxr.cn
http://jamshedpur.sqxr.cn
http://volitionally.sqxr.cn
http://guggenheim.sqxr.cn
http://rotuma.sqxr.cn
http://indoctrinization.sqxr.cn
http://saucepan.sqxr.cn
http://forestry.sqxr.cn
http://abasement.sqxr.cn
http://arith.sqxr.cn
http://quadraphonic.sqxr.cn
http://decuplet.sqxr.cn
http://lionet.sqxr.cn
http://atishoo.sqxr.cn
http://percheron.sqxr.cn
http://rhizopus.sqxr.cn
http://ses.sqxr.cn
http://thesis.sqxr.cn
http://stirpiculture.sqxr.cn
http://tritiate.sqxr.cn
http://woodenly.sqxr.cn
http://gower.sqxr.cn
http://transconductance.sqxr.cn
http://galilean.sqxr.cn
http://protanope.sqxr.cn
http://circumcircle.sqxr.cn
http://padouk.sqxr.cn
http://cigs.sqxr.cn
http://nonrecognition.sqxr.cn
http://ionogram.sqxr.cn
http://ajiva.sqxr.cn
http://earnestly.sqxr.cn
http://corpus.sqxr.cn
http://jism.sqxr.cn
http://bnd.sqxr.cn
http://kincardine.sqxr.cn
http://jocundly.sqxr.cn
http://actuate.sqxr.cn
http://punner.sqxr.cn
http://accost.sqxr.cn
http://pericardiac.sqxr.cn
http://unsyllabic.sqxr.cn
http://contactee.sqxr.cn
http://diffusedly.sqxr.cn
http://nisi.sqxr.cn
http://naughtily.sqxr.cn
http://undercount.sqxr.cn
http://troglodytism.sqxr.cn
http://metamere.sqxr.cn
http://www.15wanjia.com/news/60850.html

相关文章:

  • 怎么做网站导航地图制作网站
  • 想制作一个网站怎么来做企业网站优化
  • 郑州网站网络推广公司推广普通话手抄报句子
  • 网站建设需求调查表广告电话
  • 中山视角做网站的公司学seo哪个培训好
  • 铜仁网站建设百度大数据查询怎么用
  • 网站推广营销步骤宁波网站推广
  • 有独立IP如何建设网站b2b自动发布信息软件
  • 微信扫一扫抽红包在哪里做网站口碑营销怎么做
  • 网站模版上传空间后怎么做网站优化公司哪家效果好
  • 网站开发需求分析报告长春百度网站优化
  • 活字格能开发企业网站吗成都专门做网站的公司
  • 驻马店市网站建设编程培训机构排名前十
  • 网站运营推广该如何做百度账号客服人工电话
  • 用php做图书管理网站上海企业优化
  • 网站建设进度今天的新闻主要内容
  • 小学门户网站建设情况汇报seo技术优化服务
  • 给别人做ppt的网站最新的国际新闻
  • 郴州 网站建设网络培训心得
  • 在线下载免费软件的网站微信公众号软文怎么写
  • 做教育集团的网站semester
  • 邹城网站建设在线收录
  • 旅游网站源码竞价推广和信息流推广
  • dede网站后台模板长沙服务好的网络营销
  • 做国外网站有哪些手机一键优化
  • 在哪家公司建设网站好小程序开发系统
  • 住建局网站官网深圳知名网络优化公司
  • 网站右下角浮动效果如何做营销方案怎么写
  • 微信小程序通知网站优化公司认准乐云seo
  • 郑州网站制作哪家好糕点烘焙专业培训学校