Untitled

 avatar
user_9124840
plain_text
a month ago
335 B
3
Indexable
Never
class Solution {
public:
    int timeRequiredToBuy(vector<int>& tickets, int k) {
        
        int totalTime=0;

        for(int it:tickets)totalTime+=min(it,tickets[k]);

        for(int i=k+1;i<(int)tickets.size();++i){
            if(tickets[i]>=tickets[k])totalTime-=1;
        }
        return totalTime;
    }
};
Leave a Comment