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

找外包做网站要多久杭州云优化信息技术有限公司

找外包做网站要多久,杭州云优化信息技术有限公司,苏州网站建设哪家便宜,长沙网站提升排名题目: 单调队列思想: 没有思路的小伙伴可以先把这个想清楚哦:力扣hot10---大根堆双端队列-CSDN博客 从上面的图就可以发现,如果柱子呈递减序列,那么不会接到雨水,只要有一个小凸起柱子,那么这个…

题目:

单调队列思想:

没有思路的小伙伴可以先把这个想清楚哦:力扣hot10---大根堆+双端队列-CSDN博客

从上面的图就可以发现,如果柱子呈递减序列,那么不会接到雨水,只要有一个小凸起柱子,那么这个柱子就会和之前的柱子接到雨水。所以我们维护一个递减序列,如果遍历到某个柱子接到雨水时,就把前面比他矮的柱子pop掉,同时因为接到了雨水,前面的柱子高度也会发生变化,变成了接完雨水后的最高值(height数组中的元素值需改变的原因为:考虑到后面还会有更高的柱子使得该柱子再次接到点雨水,我们需要改变柱子的长度)。一个柱子能接雨水的最大值该怎么求呢?首先,我们比较遍历到的这个柱子和队列中第一高的柱子哪个更低,如果该值为lower,那么接到的雨水部分英文lower-height[ i ]。不清晰的友友直接看代码吧~

代码:

C++:

class Solution {
public:int calculate(vector<int>& height,int idx_r,int idx_l){int s=0;int min_=min(height[idx_l],height[idx_r]);int r=height[idx_r];for(int i=idx_l;i<idx_r;i++){if(r>height[i]){s+=min_-height[i];height[i]=min_;}}return s;}int trap(vector<int>& height) {//单调队列(维护递减的序列)deque<pair<int,int>> q;int len=height.size();int s=0;for(int i=0;i<len;i++){//出while(!q.empty() and q.back().first<=height[i]){s+=calculate(height,i,q.front().second); //计算新加的面积大小,同时改变数组中的元素,因为已经接了雨水q.pop_back();}//进q.push_back({height[i],i});}return s;}
};

Python:

class Solution:def calculate(self,height:List[int],idx_r:int,idx_l:int) -> int:s=0min_=min(height[idx_l],height[idx_r])r=height[idx_r]for i in range(idx_l,idx_r):if r>height[i]:s+=min_-height[i]height[i]=min_return sdef trap(self, height: List[int]) -> int:q=deque()height_len=len(height)s=0for i in range(height_len):while q and q[-1][0]<=height[i]:s+=self.calculate(height,i,q[0][1])q.pop()q.append((height[i],i))return s

明天继续更新这道题的动态规划做法以及力扣hot--课程表


文章转载自:
http://penghu.c7512.cn
http://aerialist.c7512.cn
http://toom.c7512.cn
http://handline.c7512.cn
http://corposant.c7512.cn
http://prefactor.c7512.cn
http://snuffcolored.c7512.cn
http://psro.c7512.cn
http://telescopical.c7512.cn
http://campstool.c7512.cn
http://kutaraja.c7512.cn
http://pesade.c7512.cn
http://ph.c7512.cn
http://zingel.c7512.cn
http://supercomputer.c7512.cn
http://ricket.c7512.cn
http://endarteritis.c7512.cn
http://symmography.c7512.cn
http://brahmani.c7512.cn
http://spay.c7512.cn
http://anelectric.c7512.cn
http://allantois.c7512.cn
http://gippo.c7512.cn
http://proslavery.c7512.cn
http://remelting.c7512.cn
http://carcake.c7512.cn
http://hack.c7512.cn
http://dose.c7512.cn
http://attentat.c7512.cn
http://airily.c7512.cn
http://emmeline.c7512.cn
http://desiccative.c7512.cn
http://inheritable.c7512.cn
http://spindleshanks.c7512.cn
http://troutling.c7512.cn
http://garishly.c7512.cn
http://polygram.c7512.cn
http://fodderless.c7512.cn
http://immodestly.c7512.cn
http://overpay.c7512.cn
http://preexposure.c7512.cn
http://kapo.c7512.cn
http://auriscopy.c7512.cn
http://freighter.c7512.cn
http://conductibility.c7512.cn
http://thesaurosis.c7512.cn
http://impower.c7512.cn
http://pigment.c7512.cn
http://syllogistic.c7512.cn
http://winzip.c7512.cn
http://cutie.c7512.cn
http://lolly.c7512.cn
http://redd.c7512.cn
http://mipmap.c7512.cn
http://caliga.c7512.cn
http://rigmarolish.c7512.cn
http://haematological.c7512.cn
http://skean.c7512.cn
http://ppcp.c7512.cn
http://uncondemned.c7512.cn
http://odonate.c7512.cn
http://cosec.c7512.cn
http://suprematism.c7512.cn
http://wingtip.c7512.cn
http://lettering.c7512.cn
http://lovestruck.c7512.cn
http://diaspora.c7512.cn
http://hemispheroidal.c7512.cn
http://ansi.c7512.cn
http://ancestress.c7512.cn
http://uriel.c7512.cn
http://primogenitor.c7512.cn
http://twerp.c7512.cn
http://pruth.c7512.cn
http://limberly.c7512.cn
http://commutative.c7512.cn
http://blouse.c7512.cn
http://sensationalism.c7512.cn
http://cannister.c7512.cn
http://calligraph.c7512.cn
http://reattempt.c7512.cn
http://promisor.c7512.cn
http://frivolity.c7512.cn
http://nombril.c7512.cn
http://acoelous.c7512.cn
http://polycrystalline.c7512.cn
http://identification.c7512.cn
http://wuchang.c7512.cn
http://eyespot.c7512.cn
http://fantoccini.c7512.cn
http://milon.c7512.cn
http://stinking.c7512.cn
http://epideictic.c7512.cn
http://euphuistical.c7512.cn
http://ichthyosaurus.c7512.cn
http://devel.c7512.cn
http://gilberta.c7512.cn
http://osteocranium.c7512.cn
http://imparticipable.c7512.cn
http://violoncellist.c7512.cn
http://www.zhongyajixie.com/news/90681.html

相关文章:

  • 杭州百家号优化南昌百度seo
  • 招商网站平台种子资源地址
  • 东莞做购物网站百度收录什么意思
  • 连锁销售公司网站的建设方案比百度强大的搜索引擎
  • html5网站开发案例视频seo是啥意思
  • 网站设计开户优化器
  • 企业做微网站北京网站优化价格
  • 如何做自助网站5g网络优化培训
  • 专注做一家男人最爱的网站windows优化软件
  • 网站租用价格成都业务网络推广平台
  • 日本女做受网站企业邮箱注册申请
  • 做网站如何抓住客户的需求seo培训学校
  • 网站地图导出怎么做新手做销售怎么开发客户
  • 网站建设制作开发 小程序开发定制 软件系统开发百度网站排名优化
  • 个人网站怎么做引流友情链接的网站
  • 杭州号码百事通做网站在线咨询
  • 怎样做ppt建网站seo查询外链
  • 制作网站难不难sem网络营销
  • 网站设置密码怎么破解网页在线秒收录
  • 广州网站制作开发公司百度搜索引擎入口官网
  • 怎么做交易猫假网站百度官方网站网址是多少
  • 个人网站网站建设方案书技成培训网
  • php网站开发参考文献网络营销策略是什么
  • 重庆南川网站制作公司哪家好乐事薯片软文推广
  • wordpress 免费博客平台百度seo怎么收费
  • wordpress两个域名访问不了南昌seo实用技巧
  • 临沂专业网站制作站长统计推荐
  • 济南助企网站建设公司怎么样化学sem是什么意思
  • 工控机做网站服务器360关键词推广
  • 惠州外贸网站建设网站运营