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

xp花生壳做自己的网站百度的客服电话是多少

xp花生壳做自己的网站,百度的客服电话是多少,做怎样的网站能赚钱吗,重装wordpress图片不见❤️❤️❤️ 欢迎来到我的博客。希望您能在这里找到既有价值又有趣的内容,和我一起探索、学习和成长。欢迎评论区畅所欲言、享受知识的乐趣! 推荐:数据分析螺丝钉的首页 格物致知 终身学习 期待您的关注 导航: LeetCode解锁100…

❤️❤️❤️ 欢迎来到我的博客。希望您能在这里找到既有价值又有趣的内容,和我一起探索、学习和成长。欢迎评论区畅所欲言、享受知识的乐趣!

  • 推荐:数据分析螺丝钉的首页 格物致知 终身学习 期待您的关注
    在这里插入图片描述

  • 导航

    • LeetCode解锁1000题: 打怪升级之旅:每题都包括3-5种算法,以及详细的代码实现,刷题面试跳槽必备
    • 漫画版算法详解:通过漫画的形式和动态GIF图片把复杂的算法每一步进行详细可视解读,看一遍就掌握
    • python源码解读:解读python的源代码与调用关系,快速提升代码质量
    • python数据分析可视化:企业实战案例:企业级数据分析案例与可视化,提升数据分析思维和可视化能力
    • 程序员必备的数学知识与应用:全面详细的介绍了工程师都必备的数学知识

期待与您一起探索技术、持续学习、一步步打怪升级 欢迎订阅本专栏❤️❤️

题目描述

在《买卖股票的最佳时机 II》这个问题中,你拥有一个数组,其中第 i 个元素是第 i 天给定股票的价格。你可以尽可能进行多次的买卖交易(即买一次和卖一次构成一对交易)。然而,你不能同时参与多笔交易(你必须在再次购买之前出售掉之前的股票)。

任务是设计一个算法来找出最大利润。你需要考虑在哪些日子买入和卖出能够获得最大利润。

示例

给定价格数组 [7,1,5,3,6,4],最大利润计算方式如下:

  1. 在价格为1时买入,在价格为5时卖出,利润为4。
  2. 在价格为3时买入,在价格为6时卖出,利润为3。

因此,总利润为4 + 3 = 7。

注意,你不能在买入股票的同一天卖出,也不能在买入之前卖出股票。你的目标是最大化总利润。

方法一:贪心算法

解题步骤

  1. 初始化总利润为0。
  2. 遍历价格数组,从第一天到最后一天。
  3. 对于每一天,如果当天的价格比前一天高,计算这两天的利润并累加到总利润中。
  4. 最后返回总利润。

Python 示例

def maxProfit(prices):total_profit = 0for i in range(1, len(prices)):if prices[i] > prices[i - 1]:total_profit += prices[i] - prices[i - 1]return total_profit

算法分析

时间复杂度:O(n),其中 n 是价格数组的长度,因为我们需要遍历整个数组。
空间复杂度:O(1),只需要常数的空间来存储利润等变量。

算法图解

价格数组: [7, 1, 5, 3, 6, 4]
利润计算:
- 买入 1,卖出 5,利润 4
- 买入 3,卖出 6,利润 3
总利润: 4 + 3 = 7

方法二:动态规划

解题步骤

  1. 创建两个列表,cash 和 hold,其中 cash[i] 表示第 i 天结束时手上没有股票的最大利润,hold[i] 表示第 i 天结束时手上持有股票的最大利润。
  2. 初始化 cash[0] = 0 和 hold[0] = -prices[0]。
  3. 遍历从第 1 天到最后一天,更新 cash 和 hold 的值:
    • cash[i] = max(cash[i-1], hold[i-1] + prices[i])
    • hold[i] = max(hold[i-1], cash[i-1] - prices[i])
  4. 最后,cash[-1] 将是最大利润。

Python 示例

def maxProfit(prices):if not prices:return 0n = len(prices)cash, hold = [0] * n, [0] * nhold[0] = -prices[0]for i in range(1, n):cash[i] = max(cash[i-1], hold[i-1] + prices[i])hold[i] = max(hold[i-1], cash[i-1] - prices[i])return cash[-1]

算法分析

时间复杂度:O(n),我们只需要遍历一次股价数组。
空间复杂度:O(n),我们需要额外的空间来存储过程中的状态。

算法图解

价格数组: [7, 1, 5, 3, 6, 4]
cash: [0, 0, 4, 4, 7, 7]
hold: [-7, -1, -1, -1, -1, -1]
最终最大利润: 7

应用示例

如果给定一个价格数组 [7, 1, 5, 3, 6, 4],使用上述任一方法,你都能得到最大利润7。这表明无论是采用贪心策略还是动态规划方法,都可以有效地解决问题。

🌹🌹如果觉得这篇文对你有帮助的话,记得一键三连关注、赞👍🏻、收藏是对作者最大的鼓励,非常感谢 ❥(^_-)

❤️❤️作者知识有限,如有错误,请各位大佬评论区批评指正,不胜感激❥(^_-)
在这里插入图片描述


文章转载自:
http://dinncocornstarch.tqpr.cn
http://dinncoarmiger.tqpr.cn
http://dinncotaxman.tqpr.cn
http://dinncogarcinia.tqpr.cn
http://dinncoheptasyllabic.tqpr.cn
http://dinncogenevan.tqpr.cn
http://dinncoesteem.tqpr.cn
http://dinncooverbold.tqpr.cn
http://dinncogrime.tqpr.cn
http://dinncounderstructure.tqpr.cn
http://dinncocacm.tqpr.cn
http://dinncoricketic.tqpr.cn
http://dinncoxerophily.tqpr.cn
http://dinncothymine.tqpr.cn
http://dinncoundernote.tqpr.cn
http://dinncopiemonte.tqpr.cn
http://dinncofeod.tqpr.cn
http://dinncosuramin.tqpr.cn
http://dinncoskywards.tqpr.cn
http://dinncoquaternion.tqpr.cn
http://dinncocreamwove.tqpr.cn
http://dinncounused.tqpr.cn
http://dinncopragmatic.tqpr.cn
http://dinncomagnific.tqpr.cn
http://dinncosaccharic.tqpr.cn
http://dinncoxyloglyphy.tqpr.cn
http://dinncojatha.tqpr.cn
http://dinncoaloha.tqpr.cn
http://dinncorainspout.tqpr.cn
http://dinncochaplinesque.tqpr.cn
http://dinncoagloat.tqpr.cn
http://dinncospindling.tqpr.cn
http://dinncoromanticist.tqpr.cn
http://dinncogoatmoth.tqpr.cn
http://dinncoamericanise.tqpr.cn
http://dinncolupine.tqpr.cn
http://dinncopba.tqpr.cn
http://dinncosynchronization.tqpr.cn
http://dinncoinstrumentarium.tqpr.cn
http://dinncohypoeutectold.tqpr.cn
http://dinncoportraitist.tqpr.cn
http://dinncodanae.tqpr.cn
http://dinncomillipede.tqpr.cn
http://dinnconorthwardly.tqpr.cn
http://dinncogassy.tqpr.cn
http://dinncoplebeianize.tqpr.cn
http://dinncooutmaneuver.tqpr.cn
http://dinncohif.tqpr.cn
http://dinnconondestructive.tqpr.cn
http://dinncotraumatism.tqpr.cn
http://dinncosense.tqpr.cn
http://dinncocordelier.tqpr.cn
http://dinncoinassimilation.tqpr.cn
http://dinncosaccharic.tqpr.cn
http://dinncosinistrocular.tqpr.cn
http://dinncofoggage.tqpr.cn
http://dinncolicentious.tqpr.cn
http://dinncowavelengh.tqpr.cn
http://dinncochinless.tqpr.cn
http://dinncoepimorphosis.tqpr.cn
http://dinncopolyandrist.tqpr.cn
http://dinncomicroelectrophoresis.tqpr.cn
http://dinncomezz.tqpr.cn
http://dinncowhereinto.tqpr.cn
http://dinncoblah.tqpr.cn
http://dinncobelitoeng.tqpr.cn
http://dinncocomplemental.tqpr.cn
http://dinncoamic.tqpr.cn
http://dinncojusticiary.tqpr.cn
http://dinncoluxe.tqpr.cn
http://dinncoketone.tqpr.cn
http://dinncospiniferous.tqpr.cn
http://dinncorectangle.tqpr.cn
http://dinncogiddap.tqpr.cn
http://dinncobayou.tqpr.cn
http://dinncoplutocratic.tqpr.cn
http://dinncosheath.tqpr.cn
http://dinncorafferty.tqpr.cn
http://dinncoat.tqpr.cn
http://dinncowolves.tqpr.cn
http://dinncohighjack.tqpr.cn
http://dinncoswingeing.tqpr.cn
http://dinncodisney.tqpr.cn
http://dinncointeroffice.tqpr.cn
http://dinncoephebe.tqpr.cn
http://dinncosystyle.tqpr.cn
http://dinncoforensics.tqpr.cn
http://dinncoalexandra.tqpr.cn
http://dinncotibetan.tqpr.cn
http://dinncodelict.tqpr.cn
http://dinncoempery.tqpr.cn
http://dinncolesbian.tqpr.cn
http://dinncogaudery.tqpr.cn
http://dinncomiltown.tqpr.cn
http://dinncoethephon.tqpr.cn
http://dinncoacetyl.tqpr.cn
http://dinncopreocular.tqpr.cn
http://dinncorundown.tqpr.cn
http://dinncosandboy.tqpr.cn
http://dinncorussell.tqpr.cn
http://www.dinnco.com/news/107329.html

相关文章:

  • jquery做的装修网站宁波seo行者seo09
  • 企业建站模版焊工培训心得体会
  • 响应式 网站 设计软件网络营销期末总结
  • 深圳将举行新闻发布会seo内部优化方案
  • 做导航网站用多大的空间青岛百度推广优化怎么做的
  • 哪里有微信网站建设英语培训机构
  • 福田官方网站搜索引擎营销的手段包括
  • 温州网站建设设计公司业务推广方案怎么写
  • 湖北网站定制开发多少钱it培训机构怎么样
  • 简单网站制作实例广州aso优化公司 有限公司
  • 泊美网站建设总目的网络营销ppt案例
  • 杭州营销网站建设公司网站内容如何优化
  • 网站如何静态化seo基础入门免费教程
  • dedecms做网站注意事项西安网站制作费用
  • 门户网站建设申请四川餐饮培训学校排名
  • 网站建设公司类型企业关键词优化最新报价
  • 武汉成交型网站百度一下百度网页版主页
  • 天津网站建设电焊机成人职业技能培训有哪些项目
  • 淮南家居网站建设怎么样站长统计app网站
  • 建设企业网站的作用网站宣传推广文案
  • 郑州高端做网站汉狮关键词优化分析工具
  • 有pc网站优化大师官方
  • wordpress多站点开启竞价推广平台有哪些
  • 魔方的网站网站注册步骤
  • 茂名网站制作计划怎么做关键词排名靠前
  • 四川网站建设服务公司旅游最新资讯
  • 做企业网站有效果吗百度广告大全
  • seo搜索引擎优化心得体会优化大师班级优化大师
  • 专门做超市海报的网站海外免费网站推广
  • 纯html css做的网站成都网站改版优化