Problem 45385. Coin distribution

Imagine, u r in a shop. ur bill is n(2200). u want to pay the bill with minimum no of coins u have.

u've coins of - 2000,1000,500,100,50,20,10,5,2,1.

There are multiple ways to do that but due to the imposed condition, the correct solution for the above scenario is -

   2000 - 1
    100 - 2

the output should be a 2D matrix of size 2-by-x; where the 1st row contains the coins u used and 2nd row contains how many.

out=[2000 100;
        1   2]

Solution Stats

66.67% Correct | 33.33% Incorrect
Last Solution submitted on Apr 05, 2020