当前位置:网站首页>[dynamic planning] change exchange
[dynamic planning] change exchange
2022-06-29 03:26:00 【A shaggy haired obeisance】
1.Leetcode Address :322. Change for - Power button (LeetCode) (leetcode-cn.com)
def coinChange(self, coins, amount):
"""
:type coins: List[int]
:type amount: int
:rtype: int
"""
dp=[amount+1 for _ in range(amount+1)]
dp[0]=0
for i in range(amount+1):
for coin in coins:
if i-coin>=0:
#if dp[i-coin]==-1:continue
dp[i]=min(dp[i],dp[i-coin]+1)
#dp[i]=-1 if dp[i]==amount+1 else dp[i]
return -1 if dp[amount]==amount+1 else dp[amount]2.
边栏推荐
- Quick sort, query the k-largest number of the sequence
- Matlab exercises - image drawing exercises
- Gartner's "voice of customers" has the highest score, and the user experience has become a major breakthrough for China's database
- Counter analysis of the parameter anti content in the backstage of the # yyds dry goods inventory # knife fight shop
- Synchronous movement state of Jerry's watch [chapter]
- 蓝桥杯2022初赛——扫雷
- Provide ideas in old texts
- Applet view creation
- Setting alarm mode of Jerry's watch [chapter]
- 2D human posture estimation deeppose
猜你喜欢

【面试指南】AI算法面试

【云原生】这么火,你不来了解下?

How to understand MySQL indexes?
![[flutter topic] 66 diagram basic constraints box (I) yyds dry goods inventory](/img/8b/55a43383e1cb6b37231dba980c7b11.jpg)
[flutter topic] 66 diagram basic constraints box (I) yyds dry goods inventory

Linear and nonlinear structures

Want to be an equipment manager? If you meet these three conditions, you can

Double click events and click events
![Synchronous movement state of Jerry's watch [chapter]](/img/58/a7e73aa32c15ccc7c506d521ca2917.jpg)
Synchronous movement state of Jerry's watch [chapter]
[email protected]"/>Unable to locate program input point [email protected]

Bluebridge cup 2022 preliminaries - minesweeping
随机推荐
Potential learning C language - pointer explanation (Advanced)
Gartner's "voice of customers" has the highest score, and the user experience has become a major breakthrough for China's database
Linear and nonlinear structures
Pat class a a1057 stack
Is it safe to open a stock account by mobile phone? Is it difficult to open an account?
leetcode:304. 二维区域和检索 - 矩阵不可变
priority_queue的理解
Stm32l4 Series MCU ADC accurately calculates input voltage through internal reference voltage
【云原生】这么火,你不来了解下?
Jerry's watch begins to move [chapter]
Solve the problem that the cursor flashes after clicking a point when measuring the distance in Allegro
[yunyuanyuan] it's so hot. Why don't you come and understand it?
There's a mystery behind the little login
FPGA (VIII) RTL code IV (basic circuit design 1)
Jerry's monitoring alarm clock [chapter]
广发证券开户是真的安全可靠吗
Etcd tutorial - Chapter 7 etcd transaction API
Vscode plug-in used now
FarrowTech的无线传感器采用橙群微电子的NanoBeacon蓝牙信标技术
Sequence traversal of binary tree ii[one of sequence traversal methods - > recursive traversal + level]