当前位置:网站首页>leetcode 322. Coin change (medium)
leetcode 322. Coin change (medium)
2022-07-01 13:29:00 【InfoQ】
One 、 The main idea of the topic
- 1 <= coins.length <= 12
- 1 <= coins[i] <= 231 - 1
- 0 <= amount <= 104
Two 、 Their thinking
3、 ... and 、 How to solve the problem
3.1 Java Realization
public class Solution {
public int coinChange(int[] coins, int amount) {
if (coins.length == 0) {
return -1;
}
int[] dp = new int[amount + 1];
Arrays.fill(dp, amount + 2);
dp[0] = 0;
for (int i = 1; i <= amount; i++) {
for (int coin : coins) {
if (i >= coin) {
dp[i] = Math.min(dp[i], dp[i - coin] + 1);
}
}
}
return dp[amount] == amount + 2 ? -1 : dp[amount];
}
}
Four 、 Summary notes
- 2022/7/1 It's Friday , Today is a connecting day
边栏推荐
- Fiori applications are shared through the enhancement of adaptation project
- Sharing with the best paper winner of CV Summit: how is a good paper refined?
- Yarn重启applications记录恢复
- Report on the current situation and development trend of bidirectional polypropylene composite film industry in the world and China Ⓟ 2022 ~ 2028
- 3.4 《数据库系统概论》之数据查询—SELECT(单表查询、连接查询、嵌套查询、集合查询、多表查询)
- Feign & Eureka & Zuul & Hystrix 流程
- 面试题目总结(1) https中间人攻击,ConcurrentHashMap的原理 ,serialVersionUID常量,redis单线程,
- Machine learning - performance metrics
- nexus搭建npm依赖私库
- 股票开户要认识谁?实际上网上开户安全么?
猜你喜欢
![[development of large e-commerce projects] performance pressure test - basic concept of pressure test & jmeter-38](/img/50/819b9c2f69534afc6dc391c9de5f05.png)
[development of large e-commerce projects] performance pressure test - basic concept of pressure test & jmeter-38

软件测试中功能测试流程

5. Use of ly tab plug-in of header component

Redis explores cache consistency

Jenkins+webhooks-多分支参数化构建-

香港科技大学李泽湘教授:我错了,为什么工程意识比上最好的大学都重要?

04-Redis源码数据结构之字典

Fiori 应用通过 Adaptation Project 的增强方式分享
基于mysql乐观锁实现秒杀的示例代码

The stack size specified is too small, specify at least 328k
随机推荐
Idea of [developing killer]
北斗通信模块 北斗gps模块 北斗通信终端DTU
硬件开发笔记(九): 硬件开发基本流程,制作一个USB转RS232的模块(八):创建asm1117-3.3V封装库并关联原理图元器件
香港科技大学李泽湘教授:我错了,为什么工程意识比上最好的大学都重要?
JS变色的乐高积木
Global and Chinese n-butanol acetic acid market development trend and prospect forecast report Ⓧ 2022 ~ 2028
Flow management technology
spark源码阅读总纲
The 14th five year plan of China's environmental protection industry and the report on the long-term goals for 2035 Ⓖ 2022 ~ 2028
Spark source code (V) how does dagscheduler taskscheduler cooperate with submitting tasks, and what is the corresponding relationship between application, job, stage, taskset, and task?
软件测试中功能测试流程
leetcode 322. Coin Change 零钱兑换(中等)
04-Redis源码数据结构之字典
leetcode 322. Coin Change 零钱兑换(中等)
Nexus builds NPM dependent private database
20个实用的 TypeScript 单行代码汇总
LeetCode重建二叉树详解[通俗易懂]
10. Page layout, guess you like it
Flinkcdc should extract Oracle in real time. What should be configured for oracle?
股票开户要认识谁?实际上网上开户安全么?