3
new long[5]; // Note: use long[] instead of int[] to avoid getting error in large testcases7
denoms = new int[] {20, 50, 100, 200, 500}; // create an array to represent money value.10
public void deposit(int[] banknotesCount) {11
for (int i = 0; i < banknotesCount.length; i++) {12
notes[i] += banknotesCount[i]; // add new deposit money to existing16
public int[] withdraw(int amount) {19
[5]; // create result array to store quantity of each notes we will be using to withdraw21
for (int i = 4; i >= 0; i--) {22
if (amount >= denoms[i]) {29
i]); // pick the minimum quanity. because if say, amount/denoms[i] gives30
// 3 but you only have 1 note. so you have to use 1 only instead of32
amount -= denoms[i] * quantity; // amount left = 10037
return new int[] {-1};39
for (int i = 0; i < 5; i++) {40
notes[i] -= result[i];41
} // deduct the quantity we have used.