Sobes.tech
Junior — Senior

Cash withdrawal module

livecode

Task condition

Given a device that stores banknotes of different denominations. It receives a Map<Integer, Integer> — where the key is the denomination of the banknote, and the value is the quantity of such banknotes. It is necessary to implement a method that can be called multiple times. The method takes the required amount and returns a map showing which banknotes and in what quantity should be issued. If it is impossible to assemble the specified amount, the method returns an error message.

Map<Integer, Integer> input = Map.of(
    50, 6,
    100, 6,
    500, 6,
    1000, 6
);
public Map<Integer, Integer> withdraw(int amount) {
    // ...
}