-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFindMinimumNumberOfCoins
45 lines (44 loc) · 1001 Bytes
/
FindMinimumNumberOfCoins
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
public class Solution
{
public static int findMinimumCoins(int amount)
{
int coin = 0;
if(amount>=1000){
coin += amount/1000;
amount = amount%1000;
}
if(amount>=500){
coin += amount/500;
amount = amount%500;
}
if(amount>=100){
coin += amount/100;
amount = amount%100;
}
if(amount>=50){
coin += amount/50;
amount = amount%50;
}
if(amount>=20){
coin += amount/20;
amount = amount%20;
}
if(amount>=10){
coin += amount/10;
amount = amount%10;
}
if(amount>=5){
coin += amount/5;
amount = amount%5;
}
if(amount>=2){
coin += amount/2;
amount = amount%2;
}
if(amount>=1){
coin += amount/1;
amount = amount%1;
}
return coin;
}
}