Ticket Purchase Time for Person at Position K
You are provided with the number of tickets each person wants to purchase while waiting in a queue. Each person in the queue takes exactly 1 second to buy a single ticket. After buying a ticket, the person moves to the end of the queue to buy additional tickets if needed. If a person runs out of tickets to purchase, they leave the queue.
Given this scenario, determine the time it takes for the person at position k (0-indexed) in the queue to finish buying tickets.
Ada AI
I want to discuss a solution
Help me solve this
Give more examples
What's wrong with my code?
How to use 'for loop' in javascript?
javascript (node 13.12.0)