C++ || queue || cycle
\nclass Solution {\npublic:\n    int timeRequiredToBuy(vector<int>& tickets, int k) {\n        queue<int> q;\n        for(int i : tickets) q.push(i);\n        i
```\nclass Solution {\npublic:\n    int timeRequiredToBuy(vector<int>& tickets, int k) {\n        queue<int> q;\n        for(int i : tickets) q.push(i);\n        int res = 0;\n        int p = k;\n        \n        while(true){\n            res++;\n            if(q.front()-- > 1) q.push(q.front());\n            else if(p == 0) break;\n            q.pop();\n            if(--p < 0) p = q.size() - 1;\n        }\n        return res;\n    }\n};\n```
['Queue', 'C']