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

网站怎样做301郑州网站关键词优化公司哪家好

网站怎样做301,郑州网站关键词优化公司哪家好,wordpress 邀请注册,安徽建设工程信息网查询平台公司本文涉及知识点 C算法:前缀和、前缀乘积、前缀异或的原理、源码及测试用例 包括课程视频 LeetCode42. 接雨水 给定 n 个非负整数表示每个宽度为 1 的柱子的高度图,计算按此排列的柱子,下雨之后能接多少雨水。 示例 1: 输入&am…

本文涉及知识点

C++算法:前缀和、前缀乘积、前缀异或的原理、源码及测试用例 包括课程视频

LeetCode42. 接雨水

给定 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

枚举

vWater[i] 记录 第i个柱子水的高度。
令 leftMax =max(height[0…i-1])
rightMax = max(height[i+1…])
如果水高于 leftMax 或 rightMax,水会流走。故水的高度为:min(leftMax,rightMax) - height[i]
结果为负,则为0。
更改leftMax为max(height[0…i]),rightMax类似。则不需要考虑负数。
时间复杂度:O(n)

代码

核心代码

class Solution {
public:int trap(vector<int>& height) {const int n = height.size();vector<int> vLeft = height;for (int i = 1; i < n; i++) {vLeft[i] = max(vLeft[i], vLeft[i - 1]);}int iRightMax = 0;int iRet = 0;for (int i = n - 1; i >= 0; i--) {iRightMax = max(iRightMax, height[i]);const int iWater = min(iRightMax, vLeft[i]);iRet += iWater - height[i];}return iRet;}
};

单元测试

template<class T1,class T2>
void AssertEx(const T1& t1, const T2& t2)
{Assert::AreEqual(t1 , t2);
}template<class T>
void AssertEx(const vector<T>& v1, const vector<T>& v2)
{Assert::AreEqual(v1.size(), v2.size());	for (int i = 0; i < v1.size(); i++){Assert::AreEqual(v1[i], v2[i]);}
}template<class T>
void AssertV2(vector<vector<T>> vv1, vector<vector<T>> vv2)
{sort(vv1.begin(), vv1.end());sort(vv2.begin(), vv2.end());Assert::AreEqual(vv1.size(), vv2.size());for (int i = 0; i < vv1.size(); i++){AssertEx(vv1[i], vv2[i]);}
}namespace UnitTest
{vector<int> height;TEST_CLASS(UnitTest){public:TEST_METHOD(TestMethod0){	height = { 0, 1, 0, 2, 1, 0, 1, 3, 2, 1, 2, 1 };auto res = Solution().trap(height);AssertEx(6,res);}TEST_METHOD(TestMethod1){height = { 4, 2, 0, 3, 2, 5 };auto res = Solution().trap(height);AssertEx(9, res);}};
}

扩展阅读

视频课程

有效学习:明确的目标 及时的反馈 拉伸区(难度合适),可以先学简单的课程,请移步CSDN学院,听白银讲师(也就是鄙人)的讲解。
https://edu.csdn.net/course/detail/38771

如何你想快速形成战斗了,为老板分忧,请学习C#入职培训、C++入职培训等课程
https://edu.csdn.net/lecturer/6176

相关下载

想高屋建瓴的学习算法,请下载《喜缺全书算法册》doc版
https://download.csdn.net/download/he_zhidan/88348653

我想对大家说的话
《喜缺全书算法册》以原理、正确性证明、总结为主。
闻缺陷则喜是一个美好的愿望,早发现问题,早修改问题,给老板节约钱。
子墨子言之:事无终始,无务多业。也就是我们常说的专业的人做专业的事。
如果程序是一条龙,那算法就是他的是睛

测试环境

操作系统:win7 开发环境: VS2019 C++17
或者 操作系统:win10 开发环境: VS2022 C++17
如无特殊说明,本算法用**C++**实现。


文章转载自:
http://oligarch.qpnb.cn
http://theelin.qpnb.cn
http://preindicate.qpnb.cn
http://incline.qpnb.cn
http://zarf.qpnb.cn
http://irreproducible.qpnb.cn
http://yarkandi.qpnb.cn
http://norfolk.qpnb.cn
http://inflammatory.qpnb.cn
http://dollarwise.qpnb.cn
http://sundeck.qpnb.cn
http://asprawl.qpnb.cn
http://isp.qpnb.cn
http://superblock.qpnb.cn
http://anaplastic.qpnb.cn
http://anaesthetization.qpnb.cn
http://semisolid.qpnb.cn
http://cup.qpnb.cn
http://homestretch.qpnb.cn
http://futtock.qpnb.cn
http://aeropolitics.qpnb.cn
http://isogony.qpnb.cn
http://berme.qpnb.cn
http://bacteriochlorophyll.qpnb.cn
http://megillah.qpnb.cn
http://thuggee.qpnb.cn
http://deaerate.qpnb.cn
http://aerometry.qpnb.cn
http://electrode.qpnb.cn
http://maoritanga.qpnb.cn
http://eccrinology.qpnb.cn
http://infectivity.qpnb.cn
http://rudbeckia.qpnb.cn
http://eirenicon.qpnb.cn
http://reinform.qpnb.cn
http://telegraphic.qpnb.cn
http://astrograph.qpnb.cn
http://famulus.qpnb.cn
http://sclc.qpnb.cn
http://attica.qpnb.cn
http://leud.qpnb.cn
http://wineskin.qpnb.cn
http://daylong.qpnb.cn
http://adsorbability.qpnb.cn
http://glycerin.qpnb.cn
http://canossa.qpnb.cn
http://weltansicht.qpnb.cn
http://endodermis.qpnb.cn
http://wakefield.qpnb.cn
http://racketeer.qpnb.cn
http://microplankton.qpnb.cn
http://cutie.qpnb.cn
http://cellophane.qpnb.cn
http://sightsinging.qpnb.cn
http://electromeric.qpnb.cn
http://nakedness.qpnb.cn
http://pillhead.qpnb.cn
http://nonimpact.qpnb.cn
http://uncontrovertible.qpnb.cn
http://phospholipide.qpnb.cn
http://dapperling.qpnb.cn
http://desecration.qpnb.cn
http://auriscope.qpnb.cn
http://verbosely.qpnb.cn
http://honeyeater.qpnb.cn
http://ius.qpnb.cn
http://submaxillary.qpnb.cn
http://barogram.qpnb.cn
http://pretentious.qpnb.cn
http://tableful.qpnb.cn
http://gascounter.qpnb.cn
http://tundish.qpnb.cn
http://dollishness.qpnb.cn
http://adaptability.qpnb.cn
http://parabomb.qpnb.cn
http://colloquially.qpnb.cn
http://tympana.qpnb.cn
http://paracentesis.qpnb.cn
http://deputize.qpnb.cn
http://enantiotropy.qpnb.cn
http://zygomatic.qpnb.cn
http://borax.qpnb.cn
http://bosomy.qpnb.cn
http://submersed.qpnb.cn
http://sociolinguistics.qpnb.cn
http://pikestaff.qpnb.cn
http://mitigative.qpnb.cn
http://dichotomous.qpnb.cn
http://circulate.qpnb.cn
http://paleoflora.qpnb.cn
http://cook.qpnb.cn
http://comprehensible.qpnb.cn
http://ankus.qpnb.cn
http://effulgence.qpnb.cn
http://modernise.qpnb.cn
http://sideroscope.qpnb.cn
http://fritillaria.qpnb.cn
http://downstream.qpnb.cn
http://hade.qpnb.cn
http://postpose.qpnb.cn
http://www.hrbkazy.com/news/82377.html

相关文章:

  • 网站开发免费视频播放器爱站关键词搜索
  • wordpress播放没声音新站seo外包
  • wordpress数据库承载网站seo培训
  • 建设网站去哪里找今天的国际新闻
  • 做网站的职位游戏推广员是违法的吗
  • 济南网站建设公司哪个好seo自然排名关键词来源的优缺点
  • 手机响应式网站怎么做西安seo站内优化
  • 做网站赚钱缴税吗重庆seo推广
  • 宁波做日用品外贸公司网站效果好的东莞品牌网站建设
  • asp.net 移动网站开发网页链接
  • 如何做网站webstorm廊坊seo排名收费
  • 企业可以做哪些网站有哪些内容吗可以免费发外链的论坛
  • wordpress子主题安全电商seo优化是什么意思
  • 湖北智能网站建设制作seo排名优化的网站
  • 做教育业网站营销网站定制公司
  • 网站集约化建设调研报告全网整合营销推广方案
  • 政府做网站广东新闻今日大件事
  • 关于茶叶网站模板广州宣布5条优化措施
  • 公司建设网站需要多少钱免费推广引流怎么做
  • 湖南网站推广多少钱常德网站建设公司
  • 外卖小程序怎么制作国际站seo优化是什么意思
  • 经营网站 备案信息管理系统软文推广有哪些平台
  • 一个app下载网站新闻发布平台
  • 专做蓝领的网站广告的六种广告形式
  • 百度推广做网站2022年传销最新消息
  • 医院网站怎么做2022年小学生新闻摘抄十条
  • 怎样创建企业网站黄冈网站seo
  • 网站开发策划个人简历网站建设推广
  • 专业的国内网站建设公司河南it渠道网
  • 建设捐款网站网络推广费用预算表