C++ || Very Easy || O(n) || My Thought
Hint :- Simple solustion is to count time for every element and return sum of it. \n\nJust bruthforces, Element before k index take min of element or that index
Hint :- Simple solustion is to count time for every element and return sum of it. \n\nJust bruthforces, Element before k index take min of element or that index value and ,after k index it take min of element-1 or that index. Here element-1 because in last round we will not go for element which index is greater then k.\n\n\n```\nclass Solution {\npublic:\n    int timeRequiredToBuy(vector<int>& tickets, int k) {\n            int ans =0;\n            int n = tickets.size();\n            int ele = tickets[k];\n            for(int i=0;i< n; i++){\n                    if(i<=k){\n                        ans+= min(ele, tickets[i]);\n                    }else{\n                        ans+= min(ele-1, tickets[i]);   \n                    }\n            }\n            return ans;\n    }\n};\n```\n\n**Upvote If like my solustion ::)**
['C', 'C++']