Solution: Make Your own Change Machine
This review provides a detailed analysis and implementation of your own change machine algorithm in Java.
We'll cover the following
Solution: The greedy way
The simple greedy idea is to start from the largest possible coin available (in our case, it is a , or ) and to keep adding coins while the remaining value is greater than .
⚠️ 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.
Level up your interview prep. Join Educative to access 80+ hands-on prep courses.