A queue of people are waiting to buy ice cream from you. Each person buys one ice cream, which sells for €5.
Each customer is holding a bank note of €5, €10 or €20. Your initial balance is 0.
Find whether you will be able to give change for every customer in the queue. You must serve customers in the order they come in.
For example
5, 5, 5, 10, 20 is true,
5, 5, 10 is true,
10, 10 is false
10, 5 is falseFollow ups:
- What if we will add new bank notes?
- How to solve the task if we will have list of available bank notes?
Comments (2)


