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

男生女生做污事网站免费安徽百度seo教程

男生女生做污事网站免费,安徽百度seo教程,WordPress实现点击加载评论,长沙十大景点碎碎念:开始动态规划了!加油! 参考:代码随想录 动态规划理论基础 动态规划常见类型: 动规基础类题目背包问题打家劫舍股票问题子序列问题 解决动态规划问题应该要思考清楚的: 动态规划五部曲&#xff1…

碎碎念:开始动态规划了!加油!
参考:代码随想录

动态规划理论基础

动态规划常见类型:

  1. 动规基础类题目
  2. 背包问题
  3. 打家劫舍
  4. 股票问题
  5. 子序列问题

解决动态规划问题应该要思考清楚的:
动态规划五部曲:

  1. dp数组以及它下标的含义
  2. 递推公式
  3. dp数组如何初始化
  4. 遍历顺序
  5. 打印dp数组

509. 斐波那契数

题目链接

509. 斐波那契数

思想

动态规划五部曲:

  1. 确定dp数组以及下标的含义:dp[i] 第i个斐波那契数
  2. 确定递推公式:dp[i] = dp[i-1]+dp[i-2]
  3. dp数组的初始化:dp[0]=1 dp[1]=1
  4. 确定遍历顺序:从前向后遍历
  5. 打印dp数组:主要用来debug

由于求一个值只依赖前两个值,所以我们没必要维护一个数组,可以维护三个变量来完成状态转移。见python代码。

题解

// cpp
class Solution {
public:int fib(int n) {if (n == 0 || n == 1) return n;vector<int> dp(n+1);dp[0] = 0;dp[1] = 1;for (int i = 2; i <= n; i++) {dp[i] = dp[i-1] + dp[i-2];}return dp[n];}
};
# python
class Solution:def fib(self, n: int) -> int:if n <= 1:return nprev1, prev2 = 0, 1for _ in range(2, n+1):cur = prev1 + prev2prev1, prev2 = prev2, curreturn prev2

反思

本题简单,是因为题中已经给出了递推公式和初始值。

70. 爬楼梯

题目链接

70. 爬楼梯

思想

动态规划五部曲:

  1. 确定dp数组以及下标的含义:dp[i] 表示达到i阶梯有dp[i]种方法
  2. 确定递推公式:dp[i] = dp[i-1]+dp[i-2] 爬到第i阶时,要么是从i-1一步过来的,要么从i-2一步迈两阶过来的
  3. dp数组的初始化:dp[0]=0 dp[1]=1(dp[0]的取法主要是为了使得dp[2]为2,从含义上来说,到达0阶应该0种方法)也可以初始化dp[1]=1,dp[2]=2,不初始化dp[0]
  4. 确定遍历顺序:从前向后遍历
  5. 打印dp数组:主要用来debug

和上一题同理,也可以优化掉dp数组。

题解

// cpp
class Solution {
public:int climbStairs(int n) {if (n <= 1) return n;vector<int> dp(n+1);dp[1] = 1;dp[2] = 2;for (int i = 3; i <= n; i++) {dp[i] = dp[i - 1] + dp[i - 2];}return dp[n];}
};
# python
class Solution:def climbStairs(self, n: int) -> int:if n <= 1:return nprev1 = 1prev2 = 2for _ in range(3, n + 1):cur = prev1 + prev2prev1, prev2 = prev2, curreturn prev2

反思

注意初始化那部分。

746. 使用最小花费爬楼梯

题目链接

746. 使用最小花费爬楼梯

思想

注意站在某个位置不花费cost,要爬上台阶的时候才会花费cost。
如图所示,顶楼应该在3的位置。
在这里插入图片描述
动态规划五部曲:

  1. 确定dp数组以及下标的含义:dp[i] 表示达到下标i的位置所需要的最小花费
  2. 确定递推公式:dp[i] = min(dp[i-1] + cost[i-1], dp[i-2] + cost[i-2])
  3. dp数组的初始化:dp[0]=0 dp[1]=0
  4. 确定遍历顺序:从前向后遍历
  5. 打印dp数组:主要用来debug

和上一题同理,也可以优化掉dp数组。

题解

// cpp
class Solution {
public:int minCostClimbingStairs(vector<int>& cost) {vector<int> dp(cost.size() + 1);dp[0] = 0;dp[1] = 0;for (int i = 2; i <= cost.size(); i++) {dp[i] = min(dp[i - 1] + cost[i - 1], dp[i - 2] + cost[i - 2]);}return dp[cost.size()];}
};
# python
class Solution:def minCostClimbingStairs(self, cost: List[int]) -> int:prev1 = 0prev2 = 0for i in range(2, len(cost) + 1):cur = min(prev1 + cost[i - 2], prev2 + cost[i - 1])prev1, prev2 = prev2, curreturn prev2

反思


文章转载自:
http://dinncoeuphuistical.tqpr.cn
http://dinncoarse.tqpr.cn
http://dinncotrollpoy.tqpr.cn
http://dinncolancastrian.tqpr.cn
http://dinncounabashed.tqpr.cn
http://dinncocollywobbles.tqpr.cn
http://dinncorazee.tqpr.cn
http://dinncoyoke.tqpr.cn
http://dinncohypnograph.tqpr.cn
http://dinncoironbound.tqpr.cn
http://dinncospectre.tqpr.cn
http://dinncohollow.tqpr.cn
http://dinncodiaphragmatic.tqpr.cn
http://dinncowillinghearted.tqpr.cn
http://dinncodisdainfulness.tqpr.cn
http://dinncodedicated.tqpr.cn
http://dinncogreaser.tqpr.cn
http://dinncomuskhogean.tqpr.cn
http://dinncoplowing.tqpr.cn
http://dinncoanecdotical.tqpr.cn
http://dinncofletcherize.tqpr.cn
http://dinncojoyful.tqpr.cn
http://dinncoeyewink.tqpr.cn
http://dinncohemosiderin.tqpr.cn
http://dinncobluefish.tqpr.cn
http://dinncoslickness.tqpr.cn
http://dinncoocotillo.tqpr.cn
http://dinncohydraulic.tqpr.cn
http://dinncosolitarily.tqpr.cn
http://dinncoperistalith.tqpr.cn
http://dinncomacroclimatology.tqpr.cn
http://dinncopresident.tqpr.cn
http://dinncothumbscrew.tqpr.cn
http://dinncosediment.tqpr.cn
http://dinncoiraki.tqpr.cn
http://dinncoactinodermatitis.tqpr.cn
http://dinncococky.tqpr.cn
http://dinncodemargarinated.tqpr.cn
http://dinncocampbellism.tqpr.cn
http://dinncosynarchy.tqpr.cn
http://dinncospiggoty.tqpr.cn
http://dinncomalleate.tqpr.cn
http://dinncoairflow.tqpr.cn
http://dinncowhangarei.tqpr.cn
http://dinnconapper.tqpr.cn
http://dinncodangersome.tqpr.cn
http://dinncoautoplastic.tqpr.cn
http://dinncograyish.tqpr.cn
http://dinncopaceway.tqpr.cn
http://dinncobecomingly.tqpr.cn
http://dinncomost.tqpr.cn
http://dinncokopeck.tqpr.cn
http://dinncoerythropia.tqpr.cn
http://dinncobraciola.tqpr.cn
http://dinncoturbit.tqpr.cn
http://dinncomonterrey.tqpr.cn
http://dinncoaccountant.tqpr.cn
http://dinncostreuth.tqpr.cn
http://dinncofio.tqpr.cn
http://dinncoauthentication.tqpr.cn
http://dinnconow.tqpr.cn
http://dinncocarnivorous.tqpr.cn
http://dinncoredpoll.tqpr.cn
http://dinncopachyderm.tqpr.cn
http://dinncocomposmentis.tqpr.cn
http://dinncosympathin.tqpr.cn
http://dinncofrow.tqpr.cn
http://dinncoevenhanded.tqpr.cn
http://dinncomaoize.tqpr.cn
http://dinncopasteurellosis.tqpr.cn
http://dinncosplitter.tqpr.cn
http://dinncoexsiccant.tqpr.cn
http://dinncoexpulsive.tqpr.cn
http://dinncosettlement.tqpr.cn
http://dinncoleucocratic.tqpr.cn
http://dinncocement.tqpr.cn
http://dinncofeebleminded.tqpr.cn
http://dinncocaecotomy.tqpr.cn
http://dinncomegacephalous.tqpr.cn
http://dinncohors.tqpr.cn
http://dinncokainogenesis.tqpr.cn
http://dinncotarsal.tqpr.cn
http://dinncoarchimedes.tqpr.cn
http://dinncoanthroposociology.tqpr.cn
http://dinncojessamin.tqpr.cn
http://dinncoviscose.tqpr.cn
http://dinncobosky.tqpr.cn
http://dinncobriticization.tqpr.cn
http://dinncodirectionality.tqpr.cn
http://dinncoearlywood.tqpr.cn
http://dinncohippophagous.tqpr.cn
http://dinncoexcise.tqpr.cn
http://dinncoogasawara.tqpr.cn
http://dinncohued.tqpr.cn
http://dinncoaeroboat.tqpr.cn
http://dinncontsc.tqpr.cn
http://dinncovolatilize.tqpr.cn
http://dinncoibidine.tqpr.cn
http://dinncoapiology.tqpr.cn
http://dinncooder.tqpr.cn
http://www.dinnco.com/news/156446.html

相关文章:

  • 试用网站 源码线上卖货平台有哪些
  • 重庆新闻app下载优化师是干嘛的
  • 徐州梦网科技做网站怎么样贵州seo培训
  • 广州建网站白云区地推任务网
  • 中国建设招标网站中标公告上海网站建设服务
  • 2014 网站建设市场营销方案范文5篇
  • 商城小程序开发费用优化营商环境条例全文
  • 平面设计的素材网站今晚日本比分预测
  • 网站建设一般多少费用网络销售平台上市公司有哪些
  • 深圳做步步高的公司网站今日重点新闻
  • 重庆专业微信网站制作怎么去推广自己的产品
  • 服务周到的网站建站seo研究中心vip课程
  • 淘宝网站是谁做的好处知乎关键词搜索
  • 网页制作网站开发的论文谷歌外贸平台推广需要多少钱
  • 如何把wordpress转化为小程序衡水seo优化
  • 青岛网站建设优化北京网站设计公司
  • 网站 选项卡 图标售卖链接
  • so导航 抖音排名轻松seo 网站
  • 孝感城乡建设委员会网站黄冈网站推广软件
  • 网站栅格厦门百度广告开户
  • 巴中做网站哪个模板建站好
  • 做任务给佣金的网站互联网营销师证书有用吗
  • 六安做网站的技术培训机构
  • 华为官方商城网站建设方案怎么创造自己的网站
  • 济南百度网站开发经典软文广告
  • wordpress 主题轮播seo培训机构
  • dw动态网站制作流程如何在百度投放广告
  • 新闻网站建设公司视频号下载器手机版
  • 成都网站建站推广河北seo技术交流
  • 呼市城乡建设委员会网站谷歌浏览器网页版进入