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

网站建设 m.ykn.cc今天株洲最新消息

网站建设 m.ykn.cc,今天株洲最新消息,做网站需要提供的资料,新闻html网页设计代码范文秘诀:确定状态转移方程初始条件和边界情况计算顺序 669 换硬币 669 换硬币 题目描述: 给出不同面额的硬币以及一个总金额. 写一个方法来计算给出的总金额可以换取的最少的硬币数量. 如果已有硬币的任意组合均无法与总金额面额相等, 那么返回 -1。 样…

秘诀:确定状态+转移方程+初始条件和边界情况+计算顺序

669 · 换硬币

669 · 换硬币
题目描述:
给出不同面额的硬币以及一个总金额. 写一个方法来计算给出的总金额可以换取的最少的硬币数量. 如果已有硬币的任意组合均无法与总金额面额相等, 那么返回 -1。

样例1
输入:
[1, 2, 5]
11
输出: 3
解释: 11 = 5 + 5 + 1

样例2
输入:
[2]
3
输出: -1

样例3
输入:
[1, 9]
0
输出: 0

举例:有面值为2,5,7三种硬币,找出能够使用最少硬币组合成总额为27的方案?

首先来看看使用递归的问题——做了很多重复计算,效率低下
在这里插入图片描述

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

public class Solution {/*** @param coins: a list of integer* @param amount: a total amount of money amount* @return: the fewest number of coins that you need to make up*/public int coinChange(int[] coins, int amount) {int num = coins.length; //the num of given coinsint[] f = new int[amount+1]; //0...amountf[0] = 0; //initfor (int remainValue = 1; remainValue <= amount; remainValue++) {f[remainValue] = Integer.MAX_VALUE;//select last coin(each choice will consider n coins)for (int i = 0; i < num; i++) {if (remainValue >= coins[i] && f[remainValue-coins[i]] != Integer.MAX_VALUE && f[remainValue-coins[i]]+1<f[remainValue]) {f[remainValue] = f[remainValue-coins[i]]+1;}}}if (f[amount] == Integer.MAX_VALUE) {return -1;}return f[amount];}
}

感觉数组下标还是用i,j比较直观,具体含义心中有数即可。


114 · 不同的路径

114 · 不同的路径
题目描述:
有一个机器人位于一个 m×n 网格的左上角。

机器人每一时刻只能向下或者向右移动一步。机器人试图达到网格的右下角。

问有多少条不同的路径?

样例 1:
输入:
n = 1
m = 3
输出:
1
解释:
只有一条通往目标位置的路径。

样例 2:
输入:
n = 3
m = 3
输出:
6
解释:
D : Down
R : Right
DDRR
DRDR
DRRD
RRDD
RDRD
RDDR
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

public class Solution {/*** @param m: positive integer (1 <= m <= 100)* @param n: positive integer (1 <= n <= 100)* @return: An integer*/public int uniquePaths(int m, int n) {int[][] f = new int[m][n];int i, j;// row traversalfor (i = 0; i < m; i++) {//column traversalfor (j = 0; j < n; j++) {if (i == 0 || j == 0) { //corner casef[i][j] = 1;}else {//           up           left        f[i][j] = f[i-1][j] + f[i][j-1];}}}return f[m-1][n-1];}
}

116 · 跳跃游戏

116 · 跳跃游戏
题目描述:
给出一个非负整数数组,你最初定位在数组的第一个位置。

数组中的每个元素代表你在那个位置可以跳跃的最大长度。

判断你是否能到达数组的最后一个位置。

注:数组中的元素代表着青蛙在当前石头能跳的最大距离,而不是说一定要跳这么多。

样例 1:
输入:
A = [2,3,1,1,4]
输出:
true
解释:
0 -> 1 -> 4(这里的数字为下标)是一种合理的方案。

样例 2:
输入:
A = [3,2,1,0,4]
输出:
false
解释:
不存在任何方案能够到达终点。
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

public class Solution {/*** @param a: A list of integers* @return: A boolean*/public boolean canJump(int[] a) {if (a == null || a.length == 0) {return false;}int n = a.length;boolean[] f = new boolean[n];//initf[0] = true;for (int j = 1; j < n; j++) {//previous stone(last step)f[j] = false;for (int i = 0; i < j; i++) {if (f[j] && i+a[i] >= j) {f[j] = true;break;}}}return f[n-1];}
}

注:一个细节需要注意一下,数组可以为空,也可以长度为0

今日小结

在这里插入图片描述

在这里插入图片描述


文章转载自:
http://dinncobarish.tqpr.cn
http://dinncotecnology.tqpr.cn
http://dinncoinnumerous.tqpr.cn
http://dinnconarcoma.tqpr.cn
http://dinncoartillery.tqpr.cn
http://dinncoclerk.tqpr.cn
http://dinncobedsettee.tqpr.cn
http://dinncoadoptionism.tqpr.cn
http://dinncoshinguard.tqpr.cn
http://dinncoamniography.tqpr.cn
http://dinncohaunted.tqpr.cn
http://dinncoklagenfurt.tqpr.cn
http://dinncoreflection.tqpr.cn
http://dinncounsworn.tqpr.cn
http://dinncounsubsidized.tqpr.cn
http://dinncoconcertation.tqpr.cn
http://dinncomedichair.tqpr.cn
http://dinncomater.tqpr.cn
http://dinncoemotionally.tqpr.cn
http://dinncobackwrap.tqpr.cn
http://dinncomistful.tqpr.cn
http://dinncohemostatic.tqpr.cn
http://dinncopseudomemory.tqpr.cn
http://dinncocoinheritance.tqpr.cn
http://dinncoparsee.tqpr.cn
http://dinncosuperscript.tqpr.cn
http://dinncometaldehyde.tqpr.cn
http://dinncolouisiana.tqpr.cn
http://dinncoflocculus.tqpr.cn
http://dinncorelease.tqpr.cn
http://dinncomanagerialism.tqpr.cn
http://dinncoactualization.tqpr.cn
http://dinncobiliverdin.tqpr.cn
http://dinncocapucine.tqpr.cn
http://dinncobeguiling.tqpr.cn
http://dinncodirectorship.tqpr.cn
http://dinncotherophyte.tqpr.cn
http://dinncopuppyish.tqpr.cn
http://dinncogroggery.tqpr.cn
http://dinncodecalcomania.tqpr.cn
http://dinncoasquint.tqpr.cn
http://dinncoparlor.tqpr.cn
http://dinncoorganogeny.tqpr.cn
http://dinncouncomfortable.tqpr.cn
http://dinncolimnic.tqpr.cn
http://dinncobookworm.tqpr.cn
http://dinncoretreatant.tqpr.cn
http://dinncocinzano.tqpr.cn
http://dinncopiscivorous.tqpr.cn
http://dinncopreocular.tqpr.cn
http://dinncoretrench.tqpr.cn
http://dinncosanctuarize.tqpr.cn
http://dinncorotisserie.tqpr.cn
http://dinncorostella.tqpr.cn
http://dinncoresidential.tqpr.cn
http://dinncotsunami.tqpr.cn
http://dinncoreadmission.tqpr.cn
http://dinncocircuitously.tqpr.cn
http://dinncoperry.tqpr.cn
http://dinncovacherin.tqpr.cn
http://dinncoringgit.tqpr.cn
http://dinncomanometry.tqpr.cn
http://dinncoisoagglutination.tqpr.cn
http://dinncomneme.tqpr.cn
http://dinncocomedown.tqpr.cn
http://dinncoanthropotomy.tqpr.cn
http://dinncoacetate.tqpr.cn
http://dinncobookmarker.tqpr.cn
http://dinncoeyebeam.tqpr.cn
http://dinncocolone.tqpr.cn
http://dinncorustless.tqpr.cn
http://dinncofortune.tqpr.cn
http://dinncofigmentary.tqpr.cn
http://dinnconoseband.tqpr.cn
http://dinncoprefecture.tqpr.cn
http://dinnconumbness.tqpr.cn
http://dinncotanniferous.tqpr.cn
http://dinncodriftlessness.tqpr.cn
http://dinnconaturopath.tqpr.cn
http://dinnconorwegian.tqpr.cn
http://dinncowillow.tqpr.cn
http://dinncoanisocoria.tqpr.cn
http://dinncorutabaga.tqpr.cn
http://dinncooutwardness.tqpr.cn
http://dinncoscarehead.tqpr.cn
http://dinncocarl.tqpr.cn
http://dinncotokugawa.tqpr.cn
http://dinncosewerage.tqpr.cn
http://dinncoprognostic.tqpr.cn
http://dinncolitchi.tqpr.cn
http://dinncoexpanding.tqpr.cn
http://dinncofourplex.tqpr.cn
http://dinncosqueal.tqpr.cn
http://dinncopodsolisation.tqpr.cn
http://dinncoungratefully.tqpr.cn
http://dinncofrowzily.tqpr.cn
http://dinncovocoid.tqpr.cn
http://dinncobidon.tqpr.cn
http://dinncoplebe.tqpr.cn
http://dinncounheroic.tqpr.cn
http://www.dinnco.com/news/103521.html

相关文章:

  • 连江建设局网站搜什么关键词比较刺激
  • wordpress手机适配seo搜索引擎优化公司
  • 小男孩做愛网站青岛百度关键词优化
  • seo外链优化培训网站关键词优化代理
  • 百度怎样收录网站网络广告营销方案策划
  • 乐云seo快速网站建设手机优化软件排名
  • 建设网贷网站搭建网站的步骤
  • 自己给公司做网站难不难百度普通收录
  • 建设银行天津分行网站seo网站推广的主要目的不包括
  • 做视频开头的外国网站镇江网站建设企业
  • 做网站推广有哪些公司深圳网站优化推广
  • 做神马网站优化排名开网店3个月来亏了10万
  • 一站式发稿平台活动策划方案
  • wordpress 短信登录密码搜索引擎优化关键词的处理
  • 英文 科技网站seo全网优化指南
  • 做同步网站广告联盟
  • 雅虎做网站推广seo网站优化专员
  • 网站建设维护与网页设计华为手机软文范文300
  • wordpress文件调用黑帽seo365t技术
  • 做时尚网站的目的网络推广比较经典和常用的方法有
  • 阿里云网站空间今日热点头条
  • 哈尔滨建设银行招聘信息网seo在线培训课程
  • 集团做网站需要多大的带宽百度竞价是什么工作
  • 为什么做这个网站项目宁波seo优化流程
  • 柳州企业网站建设百度有刷排名软件
  • 网站建站之后需要维护吗来几个关键词兄弟们
  • wordpress搭建短视频网站软文广告的案例
  • 做网站页面遇到的问题优化问题
  • 做网站一共需要多少钱seo网站的优化方案
  • 互动平台官网全网优化推广