25/28
Part 7 of 7 · What interviewers ask nextLearn and do
Very large amounts: shrink the unit by the GCD
At $10,000,000 the table has a billion cells. There are three answers, and they stack: shrink the unit, check whether greedy is safe, and bound the table by the largest coin. Start with the cheapest.
Shrink the unit. Divide the amount and every coin by the coins' GCD, and fill the table in that unit. An amount the GCD doesn't divide is -1 at once.
Coins of 5, 10 and 25 cents. Counting in their GCD makes the table how much shorter?
Pick an answer above to see the rest