Simple C++ code
If you like the implementation then Please help me by increasing my reputation. By clicking the up arrow on the left of my image.\n\nclass Solution {\npublic:\n
# **If you like the implementation then Please help me by increasing my reputation. By clicking the up arrow on the left of my image.**\n```\nclass Solution {\npublic:\n    int timeRequiredToBuy(vector<int>& tickets, int k) {\n        queue<pair<int,int>>q;\n        int time = 0;\n        for(int i = 0; i < tickets.size(); i++)\n        {\n            q.push({tickets[i],i});\n        }\n        while(!q.empty())\n        {\n            pair<int,int> tmp = q.front();\n            q.pop();\n            --tmp.first;\n            ++time;\n            if(tmp.first == 0 && tmp.second == k)\n            {\n                break;\n            }\n            else if(tmp.first != 0)\n            {\n                q.push({tmp.first,tmp.second});\n            }\n        }\n        return time;\n    }\n};\n```
['Queue']