This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Aleks is a strawberry merchant, selling strawberries at a price of €5 for 1 kilogram. | |
Each customer can only buy 1 KG of strawberries, but can pay with €5, €10 or €20 bills. | |
When a customer is paying with a bill of more than €5, Aleks needs to return correct change. | |
Given an array of customers represented with the bills with which they are paying, | |
your function should return true if Aleks can serve each customer in the queue | |
(either the customer is paying the exact price or Aleks will need to return the correct change), | |
or false otherwise. | |
Example 1: input array is: [5, 10, 5, 20]; should return true because: |