C++ || EASY || O(n)
Upvote If you like the solution\n\nclass Solution {\npublic:\n    int timeRequiredToBuy(vector<int>& tickets, int k) {\n        int num=tickets[k],tt=0;\n      
***Upvote If you like the solution***\n```\nclass Solution {\npublic:\n    int timeRequiredToBuy(vector<int>& tickets, int k) {\n        int num=tickets[k],tt=0;\n        for(int i=0;i<tickets.size();i++){\n            if(num>tickets[i]){\n                tt+=tickets[i];\n            }\n            else if(num<=tickets[i]){\n                tt+=num;\n            }\n        }\n        for(int i=k+1;i<tickets.size();i++){\n            if(tickets[i]>=num){\n                tt-=1;\n            }\n        }\n        return tt;\n    }\n};\n```
['C', 'C++']