easy to understand
\nvar timeRequiredToBuy = function(tickets, k) {\n     \n    let countTime = 0;\n\n    while(tickets[k] !== 0){\n\n        for(let i = 0; i < tickets.length; i+
```\nvar timeRequiredToBuy = function(tickets, k) {\n     \n    let countTime = 0;\n\n    while(tickets[k] !== 0){\n\n        for(let i = 0; i < tickets.length; i++){\n            \n            if(tickets[k] == 0){\n                return countTime;\n            }\n            if(tickets[i] !== 0){\n                tickets[i] = tickets[i] - 1;\n                countTime++;\n            }\n        }\n\n    }\n\n    return countTime;\n};\n```
['JavaScript']