...

/

Solution: Make Your own Change Machine

Solution: Make Your own Change Machine

This review provides a detailed analysis and implementation of your own change machine algorithm in Java.

Solution: The greedy way

The simple greedy idea is to start from the largest possible coin available (in our case, it is a quarterquarter, or 25 cents25\ cents) and to keep adding coins while the remaining value is greater than 00.

⚠️ Warning!

This is not the most optimized solution. It is only to give you an idea of how the greedy algorithm works. If you want to look at the most optimized version have a look at it in the (previous) Dynamic Programming section.

Access this course and 1400+ top-rated courses and projects.