当前位置:网站首页>322. change exchange
322. change exchange
2022-06-23 07:08:00 【Graduation_ Design】
Preface
C++ It's a high-level programming language , from C Language expansion and upgrading , As early as 1979 By Benjani · Strauss LUP is AT&T Developed by Bell studio .
C++ Both can be carried out C Process programming of language , It can also be used for object-based programming characterized by abstract data types , It can also carry out object-oriented programming characterized by inheritance and polymorphism .C++ Good at object-oriented programming at the same time , You can also do process based programming .
C++ Have the practical characteristics of computer operation , At the same time, it is also committed to improving the programming quality of large-scale programs and the problem description ability of programming languages .
Java Is an object-oriented programming language , Not only absorbed C++ The advantages of language , It's abandoned C++ The incomprehensible inheritance in 、 Concepts such as pointer , therefore Java Language has two characteristics: powerful and easy to use .Java As the representative of static object-oriented programming language , Excellent implementation of object-oriented theory , Allow programmers to do complex programming in an elegant way of thinking .
Java It's simple 、 object-oriented 、 Distributed 、 Robustness, 、 Security 、 Platform independence and portability 、 Multithreading 、 Dynamic and so on .Java Can write desktop applications 、Web Applications 、 Distributed system and embedded system applications, etc .
Python By Guido of the Dutch Society for mathematical and computer science research · Van rosum On 1990 It was designed in the early 's , As a course called ABC A substitute for language .Python Provides efficient advanced data structure , It's also a simple and effective way of object-oriented programming .Python Syntax and dynamic types , And the nature of interpretative language , Make it a programming language for scripting and rapid application development on most platforms , With the continuous update of the version and the addition of new language features , Gradually used for independent 、 Development of large projects .
Python The interpreter is easy to extend , have access to C Language or C++( Or something else can be done through C Calling language ) Expand new functions and data types .Python It can also be used as an extensible programming language in customizable software .Python Rich library of standards , Provides source code or machine code for each major system platform .
2021 year 10 month , Compiler for language popularity index Tiobe take Python Crowned the most popular programming language ,20 Put it in... For the first time in years Java、C and JavaScript above .
describe
Give you an array of integers coins , Coins of different denominations ; And an integer amount , Represents the total amount .
Calculate and return the amount needed to make up the total amount The minimum number of coins . If no combination of coins can make up the total amount , return -1 .
You can think of the number of coins of each kind as infinite .
Example 1:
Input :coins = [1, 2, 5], amount = 11
Output :3
explain :11 = 5 + 5 + 1
Example 2:
Input :coins = [2], amount = 3
Output :-1
Example 3:
Input :coins = [1], amount = 0
Output :0
public class Solution {
public int coinChange(int[] coins, int amount) {
if (amount < 1) {
return 0;
}
return coinChange(coins, amount, new int[amount]);
}
private int coinChange(int[] coins, int rem, int[] count) {
if (rem < 0) {
return -1;
}
if (rem == 0) {
return 0;
}
if (count[rem - 1] != 0) {
return count[rem - 1];
}
int min = Integer.MAX_VALUE;
for (int coin : coins) {
int res = coinChange(coins, rem - coin, count);
if (res >= 0 && res < min) {
min = 1 + res;
}
}
count[rem - 1] = (min == Integer.MAX_VALUE) ? -1 : min;
return count[rem - 1];
}
}
边栏推荐
- 【BULL中文文档】用于在 NodeJS 中处理分布式作业和消息的队列包
- Detailed explanation of callback function
- Vs2013 ffmpeg environment configuration and common error handling
- Endnote20 tutorial sharing (unfinished
- 20220620 uniformly completely observable (UCO)
- xml schem 记录
- 2121. 相同元素的间隔之和-哈希表法
- Mongodb record
- Xshell7 Download
- 产品-Axure9(英文版),原型设计后台动态二级菜单显示内容
猜你喜欢

Badly placed()'s problem

数据在内存中的存储方式(C语言)

20220621 Dual Quaternion

正则表达式图文超详细总结不用死记硬背(上篇)

Xiaobai must see in investment and wealth management: illustrated fund buying and selling rules

mysql 优化

Common setup modes (Abstract Factory & responsibility chain mode & observer mode)

xml schem 记录

Swagger3 integrates oauth2 authentication token

Idea automatically generates serialVersionUID
随机推荐
centos7 mysql 记录
core. What is JS ---kalrry
XML schema record
Intentional shared lock, intentional exclusive lock and deadlock of MySQL
C DPI adaptation problem
[STL] summary of map usage of associated containers
【项目实训】多段线扩充为平行线
[project training 10] drawing of arrows
mysql 基础查询
994. 腐烂的橘子-非递归法
在金融行业做数据产品经理是什么体验
Verilog syntax explanation
Cetos7 record
产品-Axure9(英文版),原型设计后台动态二级菜单显示内容
C language operator priority formula
mysql 索引
回调函数详解
How to migrate virtual machines from VirtualBox to hype-v
306. 累加数
深度学习系列46:人脸图像超分GFP-GAN