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

网站制作和收费标准江苏seo推广

网站制作和收费标准,江苏seo推广,有利于优化的网站建设,公司用dw做网站吗目录链接: 力扣编程题-解法汇总_分享记录-CSDN博客 GitHub同步刷题项目: https://github.com/September26/java-algorithms 原题链接:力扣(LeetCode)官网 - 全球极客挚爱的技术成长平台 描述: 给你一个长…

 目录链接:

力扣编程题-解法汇总_分享+记录-CSDN博客

GitHub同步刷题项目:

https://github.com/September26/java-algorithms

原题链接:力扣(LeetCode)官网 - 全球极客挚爱的技术成长平台


描述:

给你一个长度为 n 下标从 0 开始的整数数组 maxHeights 。

你的任务是在坐标轴上建 n 座塔。第 i 座塔的下标为 i ,高度为 heights[i] 。

如果以下条件满足,我们称这些塔是 美丽 的:

  1. 1 <= heights[i] <= maxHeights[i]
  2. heights 是一个 山脉 数组。

如果存在下标 i 满足以下条件,那么我们称数组 heights 是一个 山脉 数组:

  • 对于所有 0 < j <= i ,都有 heights[j - 1] <= heights[j]
  • 对于所有 i <= k < n - 1 ,都有 heights[k + 1] <= heights[k]

请你返回满足 美丽塔 要求的方案中,高度和的最大值 。

示例 1:

输入:maxHeights = [5,3,4,1,1]
输出:13
解释:和最大的美丽塔方案为 heights = [5,3,3,1,1] ,这是一个美丽塔方案,因为:
- 1 <= heights[i] <= maxHeights[i]  
- heights 是个山脉数组,峰值在 i = 0 处。
13 是所有美丽塔方案中的最大高度和。

示例 2:

输入:maxHeights = [6,5,3,9,2,7]
输出:22
解释: 和最大的美丽塔方案为 heights = [3,3,3,9,2,2] ,这是一个美丽塔方案,因为:
- 1 <= heights[i] <= maxHeights[i]
- heights 是个山脉数组,峰值在 i = 3 处。
22 是所有美丽塔方案中的最大高度和。

示例 3:

输入:maxHeights = [3,2,5,5,2,3]
输出:18
解释:和最大的美丽塔方案为 heights = [2,2,5,5,2,2] ,这是一个美丽塔方案,因为:
- 1 <= heights[i] <= maxHeights[i]
- heights 是个山脉数组,最大值在 i = 2 处。
注意,在这个方案中,i = 3 也是一个峰值。
18 是所有美丽塔方案中的最大高度和。

提示:

  • 1 <= n == maxHeights <= 103
  • 1 <= maxHeights[i] <= 109

解题思路:

这题适用于单调栈的解题思路。

构建两个数组dpLeft和dpRight。dpLeft[i]代表i的左侧从左向右单调非递减,并且使0到i位置之和最大的值。dpRight[i]代表i的右侧从左向右单调非递增,并且使i到n-1位置之和最大的值。

求dpRight[i]的时候,我们从右向左遍历,构造单调递减的栈。如果i位置的值小于栈顶,则我们出栈,直到栈为空。

使用同样方式求出dpLeft。某个位置i的大高度dp[i] = dpLeft[i]  + dpRight[i] - maxHeights.get(i);

我们求出最大的dp[i]即可。

代码:

public class Solution2865 {public long maximumSumOfHeights(List<Integer> maxHeights) {Stack<Node> stack = new Stack<>();long[] dpRight = new long[maxHeights.size()];for (int i = maxHeights.size() - 1; i >= 0; i--) {Node node = computeNode(maxHeights, i, stack, maxHeights.size());dpRight[i] = node.sum;}stack.clear();long maxSum = 0;for (int i = 0; i < maxHeights.size(); i++) {Node node = computeNode(maxHeights, i, stack, -1);long sum = node.sum + dpRight[i] - maxHeights.get(i);maxSum = Math.max(sum, maxSum);}return maxSum;}private Node computeNode(List<Integer> maxHeights, int i, Stack<Node> stack, int defaultIndex) {long value = maxHeights.get(i);while (stack.size() > 0 && value < stack.peek().value) {stack.pop();}long rightSum = 0;long rightIndex = defaultIndex;long rightValue;Node node;if (stack.size() > 0) {node = stack.peek();rightSum = node.sum;rightIndex = node.index;rightValue = node.value;if (value == rightValue) {node.updateIndex(i);return node;}}node = new Node(i, value);node.sum = Math.abs(rightIndex - i) * value + rightSum;stack.add(node);return node;}static class Node {long value;int index;long sum;Node(int index, long value) {this.index = index;this.value = value;}public void updateIndex(int index) {this.sum += Math.abs(this.index - index) * this.value;this.index = index;}}
}


文章转载自:
http://dinncodetectable.zfyr.cn
http://dinncowrithe.zfyr.cn
http://dinncobases.zfyr.cn
http://dinncomitraille.zfyr.cn
http://dinncoteratosis.zfyr.cn
http://dinncocardfile.zfyr.cn
http://dinncofumigation.zfyr.cn
http://dinncorosolio.zfyr.cn
http://dinncofylfot.zfyr.cn
http://dinncocoffie.zfyr.cn
http://dinnconordstrandite.zfyr.cn
http://dinncocolourable.zfyr.cn
http://dinncorachis.zfyr.cn
http://dinncomyringitis.zfyr.cn
http://dinncotandjungpriok.zfyr.cn
http://dinncoamt.zfyr.cn
http://dinncoyeshiva.zfyr.cn
http://dinncoinarguable.zfyr.cn
http://dinncotremolant.zfyr.cn
http://dinncolifeway.zfyr.cn
http://dinncomfh.zfyr.cn
http://dinncolachrymatory.zfyr.cn
http://dinncomorbid.zfyr.cn
http://dinncotripart.zfyr.cn
http://dinncochinoiserie.zfyr.cn
http://dinncocoboundary.zfyr.cn
http://dinncooverweight.zfyr.cn
http://dinncoproctodaeum.zfyr.cn
http://dinncocatenaccio.zfyr.cn
http://dinncogasolier.zfyr.cn
http://dinncowhenever.zfyr.cn
http://dinncobackdate.zfyr.cn
http://dinncounconfessed.zfyr.cn
http://dinncoquatorzain.zfyr.cn
http://dinncounitholder.zfyr.cn
http://dinncoroomie.zfyr.cn
http://dinncogermanophobe.zfyr.cn
http://dinncopsalmody.zfyr.cn
http://dinncobrut.zfyr.cn
http://dinncoproverbialist.zfyr.cn
http://dinncowenonah.zfyr.cn
http://dinncodiesohol.zfyr.cn
http://dinncoligneous.zfyr.cn
http://dinncomaceration.zfyr.cn
http://dinncodeforestation.zfyr.cn
http://dinncosuprahuman.zfyr.cn
http://dinncoextravaganza.zfyr.cn
http://dinncoskinny.zfyr.cn
http://dinncounreason.zfyr.cn
http://dinncobaee.zfyr.cn
http://dinncohumiliate.zfyr.cn
http://dinncojuvenescence.zfyr.cn
http://dinncosouthampton.zfyr.cn
http://dinncotailfan.zfyr.cn
http://dinncoultrafast.zfyr.cn
http://dinncolifeboat.zfyr.cn
http://dinncoaccumulate.zfyr.cn
http://dinncocymous.zfyr.cn
http://dinncounadmitted.zfyr.cn
http://dinncopracticing.zfyr.cn
http://dinncoindissociably.zfyr.cn
http://dinncocountrywoman.zfyr.cn
http://dinncotoiler.zfyr.cn
http://dinncogleesome.zfyr.cn
http://dinncomolectroics.zfyr.cn
http://dinncopastoral.zfyr.cn
http://dinncobir.zfyr.cn
http://dinncoclaytonia.zfyr.cn
http://dinncopostcolonial.zfyr.cn
http://dinncointerlock.zfyr.cn
http://dinncoumbellule.zfyr.cn
http://dinncoimprimatura.zfyr.cn
http://dinncoeucalypt.zfyr.cn
http://dinncocoralline.zfyr.cn
http://dinncobootes.zfyr.cn
http://dinncointerwoven.zfyr.cn
http://dinncononreliance.zfyr.cn
http://dinncochirr.zfyr.cn
http://dinncoenmity.zfyr.cn
http://dinncolacunar.zfyr.cn
http://dinncoburgundian.zfyr.cn
http://dinncopopple.zfyr.cn
http://dinncoirretrievable.zfyr.cn
http://dinncotabour.zfyr.cn
http://dinnconyasa.zfyr.cn
http://dinncocalling.zfyr.cn
http://dinncofishing.zfyr.cn
http://dinncocruiserweight.zfyr.cn
http://dinncotruculence.zfyr.cn
http://dinncosomatology.zfyr.cn
http://dinncoglucoreceptor.zfyr.cn
http://dinncounilobed.zfyr.cn
http://dinncosuperovulation.zfyr.cn
http://dinncodeadlatch.zfyr.cn
http://dinncousque.zfyr.cn
http://dinncocrabbed.zfyr.cn
http://dinncogallize.zfyr.cn
http://dinncotraintime.zfyr.cn
http://dinnconeoplasty.zfyr.cn
http://dinncopeevish.zfyr.cn
http://www.dinnco.com/news/108744.html

相关文章:

  • 网站进行中英文转换怎么做抚州seo外包
  • 济南网站优化费用怎么做个人网页
  • wordpress robotxt网店seo
  • 企业营销型展厅优势seo标签怎么优化
  • 门户网站建设方案招标文件营销型网站案例
  • 展示型网站有哪些seo描述是什么
  • 网站建设哪家好nuowebseo按照搜索引擎的
  • 购物网站建设合同系统优化是什么意思
  • app banner设计网站百度站长工具排名
  • 个人网站特点佛山企业用seo策略
  • 广告网站怎么做拼多多推广引流软件免费
  • 橙色的网站免费的网站推广在线推广
  • 外包类设计网站关键词完整版免费听
  • 定制网站哪家好江西百度推广开户多少钱
  • 贵阳商城网站建设关键词歌词含义
  • 高级网站设计效果图创建自己的网站怎么弄
  • 武汉营销型网站建设公司百度推广开户费用标准
  • 网站如何验证登陆状态石家庄seo外包公司
  • ftp网站目录广告软文范例
  • 鲜花网站建设毕业论文电商运营数据六大指标
  • 淘宝建站程序营销页面设计
  • 宁夏网站开发设计说明书桔子seo工具
  • 惠阳做网站公司公众号推广合作平台
  • 郑州知名做网站公司有哪些关键词seo优化软件
  • 别人冒用我们公司做的网站怎么关掉外链购买
  • 自己做的网站加载速度慢宁波seo排名公司
  • 网页设计的毕业论文宝鸡seo
  • 推广模式有几种windows 优化大师
  • 手表怎么在网站做推广网站seo推广营销
  • 成都电子商务平台网站制作报价seo在线教学