Tag Archive for: buy

Time waiting to buy my tickets

Imagine you are in a queue, every time you reach the first position you can buy just one ticket. Buyers have to wait through the line again if they want to buy more tickets. You are standing in line and has a number of tickets to purchase.

Given a list of buyers with the number of tickets they want to buy, determine how long it will take you to purchase your tickets if you are in the second position. Each transaction takes 1 unit of time. No time is spent moving to the back of the line.