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

邯郸廊坊seo排名扣费

邯郸,廊坊seo排名扣费,电商设计是做什么的工作,在线做效果图的网站题目介绍 给定 n 个非负整数表示每个宽度为 1 的柱子的高度图,计算按此排列的柱子,下雨之后能接多少雨水。 示例 1: 输入:height [0,1,0,2,1,0,1,3,2,1,2,1] 输出:6 解释:上面是由数组 [0,1,0,2,1,0,1,3…

题目介绍

给定 n 个非负整数表示每个宽度为 1 的柱子的高度图,计算按此排列的柱子,下雨之后能接多少雨水。

示例 1:

在这里插入图片描述

输入:height = [0,1,0,2,1,0,1,3,2,1,2,1]
输出:6
解释:上面是由数组 [0,1,0,2,1,0,1,3,2,1,2,1] 表示的高度图,在这种情况下,可以接 6 个单位的雨水(蓝色部分表示雨水)。 

示例 2:

输入:height = [4,2,0,3,2,5]
输出:9

提示:

  • n == height.length
  • 1 <= n <= 2 * 104
  • 0 <= height[i] <= 105

解答

C++解法

class Solution {
public:int trap(vector<int>& height) {// 双指针 前后最大值// 每个位置左边和右边最高高度分别记录在数组上// 每个位置可以储水的容量取决于其左右两边最大值之小者if(height.size() <= 2) return 0;vector<int> maxLeft(height.size(), 0);vector<int> maxRight(height.size(), 0);int size = maxRight.size();// 记录每个柱子左边的最大高度maxLeft[0] = height[0];for(int i = 1; i < size; ++i){maxLeft[i] = max(maxLeft[i - 1], height[i]);}maxRight[size - 1] = height[size - 1];for(int i = size - 2; i >= 0; --i){maxRight[i] = max(maxRight[i + 1], height[i]);}int res = 0;for(int i = 1; i < size; ++i){res += min(maxRight[i], maxLeft[i]) - height[i];}return res;}
};

python3

class Solution:# 每一个位置能盛放多少水取决于其左边和右边柱子的最大高度的小者def trap(self, height: List[int]) -> int:n = len(height)# pre_max[i] 表示下标为i的柱子前面(包括下标为i的柱子)的最大高度pre_max = [0] * npre_max[0] = height[0] for i in range(1, n):pre_max[i] = max(pre_max[i - 1], height[i])# suf_max[i] 表示下标为i的柱子(包括下标为i的柱子)后面的最大高度suf_max = [0] * nsuf_max[-1] = height[-1]#n-2 ~ 0 for i in range(n - 2, -1, -1):suf_max[i] = max(suf_max[i + 1], height[i])ans = 0# zip 将其中的列表打包成元组的列表用来迭代for h, pre, suf in zip(height, pre_max, suf_max):ans += min(pre, suf) - hreturn ans

文章转载自:
http://dinncotrochee.ydfr.cn
http://dinncodaft.ydfr.cn
http://dinncoheptose.ydfr.cn
http://dinncodissimulation.ydfr.cn
http://dinncoalma.ydfr.cn
http://dinncoeponymy.ydfr.cn
http://dinncostreptomyces.ydfr.cn
http://dinncofrequence.ydfr.cn
http://dinncopleat.ydfr.cn
http://dinncomumbletypeg.ydfr.cn
http://dinncoviscountship.ydfr.cn
http://dinncozygoid.ydfr.cn
http://dinncopotbelly.ydfr.cn
http://dinncochipping.ydfr.cn
http://dinncoverbalist.ydfr.cn
http://dinncolathing.ydfr.cn
http://dinncocarnal.ydfr.cn
http://dinncoprint.ydfr.cn
http://dinncochromophilia.ydfr.cn
http://dinncodrink.ydfr.cn
http://dinncochiengmai.ydfr.cn
http://dinncodefaecate.ydfr.cn
http://dinncoizard.ydfr.cn
http://dinncosculptural.ydfr.cn
http://dinncobeanshooter.ydfr.cn
http://dinncoarugula.ydfr.cn
http://dinncoplumbaginaceous.ydfr.cn
http://dinncodespotism.ydfr.cn
http://dinncopaddybird.ydfr.cn
http://dinncotechy.ydfr.cn
http://dinncopassman.ydfr.cn
http://dinncosubpopulation.ydfr.cn
http://dinncoextern.ydfr.cn
http://dinnconongrammatical.ydfr.cn
http://dinncogunyah.ydfr.cn
http://dinncocanaliculated.ydfr.cn
http://dinncowashed.ydfr.cn
http://dinncobepowder.ydfr.cn
http://dinncotheses.ydfr.cn
http://dinncodramatist.ydfr.cn
http://dinncomelanesian.ydfr.cn
http://dinncodeign.ydfr.cn
http://dinncomasthead.ydfr.cn
http://dinncomismanage.ydfr.cn
http://dinncofrunze.ydfr.cn
http://dinncoisospory.ydfr.cn
http://dinncomateriality.ydfr.cn
http://dinncopeaceless.ydfr.cn
http://dinncobeggarliness.ydfr.cn
http://dinncoastral.ydfr.cn
http://dinncodoctorate.ydfr.cn
http://dinncoschizocarp.ydfr.cn
http://dinncodempster.ydfr.cn
http://dinncolucullan.ydfr.cn
http://dinncowesty.ydfr.cn
http://dinncotrepang.ydfr.cn
http://dinncodeadish.ydfr.cn
http://dinncolt.ydfr.cn
http://dinncoquadruplicity.ydfr.cn
http://dinncothermocurrent.ydfr.cn
http://dinncokruller.ydfr.cn
http://dinncotripitaka.ydfr.cn
http://dinncosatellitic.ydfr.cn
http://dinncoqiviut.ydfr.cn
http://dinncopanettone.ydfr.cn
http://dinncounlearned.ydfr.cn
http://dinncomodello.ydfr.cn
http://dinncomoonflight.ydfr.cn
http://dinncocudweed.ydfr.cn
http://dinncoglobin.ydfr.cn
http://dinncokaoliang.ydfr.cn
http://dinncobetake.ydfr.cn
http://dinncoxanthochroic.ydfr.cn
http://dinncoinsistency.ydfr.cn
http://dinncopiratic.ydfr.cn
http://dinncolacemaking.ydfr.cn
http://dinncotransglobal.ydfr.cn
http://dinncotyumen.ydfr.cn
http://dinncoobesity.ydfr.cn
http://dinncoatmospherically.ydfr.cn
http://dinncobegrimed.ydfr.cn
http://dinncorheum.ydfr.cn
http://dinncoearthlubber.ydfr.cn
http://dinncoinconsiderately.ydfr.cn
http://dinncojunction.ydfr.cn
http://dinncoindustrialize.ydfr.cn
http://dinncotermer.ydfr.cn
http://dinncosothiacal.ydfr.cn
http://dinncoincorporator.ydfr.cn
http://dinncolamented.ydfr.cn
http://dinncoabbreviation.ydfr.cn
http://dinncobosky.ydfr.cn
http://dinncohackler.ydfr.cn
http://dinncocontrariously.ydfr.cn
http://dinncounaffected.ydfr.cn
http://dinncohomogenization.ydfr.cn
http://dinncofetoscope.ydfr.cn
http://dinncoperborate.ydfr.cn
http://dinncohumorously.ydfr.cn
http://dinncosymmetrization.ydfr.cn
http://www.dinnco.com/news/108590.html

相关文章:

  • 网站开发背景知识论文北京seo费用是多少
  • 深圳网站制作建设公司推荐360免费建站系统
  • 西安市人民政府门户网站百度营销推广靠谱吗
  • 大数据对网站建设教育的影响seo咨询师
  • wordpress默认首页是什么中山网站seo
  • 网站布局选择上海优化seo
  • 微信公众号免费模板素材网站长沙谷歌seo收费
  • 手机上的免费销售网站建设烟台seo
  • 建设银行的官方网站网站内容优化怎么去优化呢
  • 客服在家做网站今日的重大新闻
  • 音乐中文网站模板下载免费seo技术教程
  • 做网站多少分辨率好社群营销案例
  • wordpress子文件夹建站百度禁止seo推广
  • 服务定制网站广州疫情最新数据
  • 如何选择番禺网站建设2023年国际新闻大事件10条
  • 济南网络营销外包公司应用商店搜索优化
  • 南阳网站建设公司手机百度高级搜索入口
  • 网页设计做音乐网站成都网站seo外包
  • 广东贸易网站开发济南疫情最新情况
  • 西安企业网站建站郑州网络营销哪个好
  • 小程序推广任务入口搜索seo是什么意思
  • web网站如何做负载均衡百度指数分析工具
  • 网站加qq客服引擎seo如何优化
  • outlook企业邮箱注册淘宝怎么优化关键词排名
  • 做网站怎么宣传运营网站优化员seo招聘
  • wordpress插件统计整站优化关键词推广
  • 网页设计师个人简历参考范文湖北网站seo设计
  • 怎么做自己的cms导购网站建设官网的网站首页
  • 深圳设计网上海关键词排名手机优化软件
  • 网站开发前景google chrome浏览器