leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

2073.cpp (326B)


      1 class Solution {
      2   public:
      3     int timeRequiredToBuy(vector<int> &tickets, int k) {
      4         int time = 0;
      5         for (int i = 0; i < tickets.size(); i++)
      6             if (tickets[i] >= tickets[k])
      7                 time += tickets[k] - (i > k);
      8             else
      9                 time += tickets[i];
     10         return time;
     11     }
     12 };