FunctionRacerProblemsRace

Greedy Coins

BeginnerGreedyPython, JavaScript, TypeScript, Java, C++

Using US coins worth 25, 10, 5 and 1 cents (as many of each as you need), return the smallest number of coins that add up to exactly cents.

Example 1

cents 41
returns 4

25 + 10 + 5 + 1 = 4 coins.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Greedy problems