Skip to content

Instantly share code, notes, and snippets.

@ucfjoe
ucfjoe / strawberryMerchantChallenge
Created September 2, 2025 06:43
Cart Foundation Coding Interview
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: