The worst case
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n``` javascript []\n/**\n * @param {number[]} tickets\n * @param {number} k\n * @return {number}\n */\nvar timeRequiredToBuy = function(tickets, k) {\n    let timer = 0;\n    while(tickets[k] > 0) {\n        timer++;\n        tickets[0]--;\n        \n        if(k==0 && tickets[k]==0) break;\n\n        let a = tickets.shift();\n        if(a > 0) tickets.push(a);\n\n        if(k==0) k = tickets.length-1;\n        else k--;\n        \n    }\n    return timer;\n};\n```\n``` cpp []\nclass Solution {\npublic:\n    int timeRequiredToBuy(vector<int>& tickets, int k) {\n        int timer = 0;\n        while(tickets[k] > 0) {\n            timer++;\n\n            tickets[0]--;\n            \n            if(k==0 && tickets[k]==0) break;\n\n            int a = tickets[0];\n            tickets.erase(tickets.begin());\n            if(a > 0) tickets.push_back(a);\n\n            if(k==0) k = tickets.size()-1;\n            else k--;\n        }\n        return timer;\n    }\n};\n```
['C++', 'JavaScript']