leetcode

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

2274.cpp (490B)


      1 class Solution {
      2   public:
      3     int maxConsecutive(int bottom, int top, vector<int> &special) const {
      4         int res = 0, i;
      5 
      6         sort(begin(special), end(special));
      7         for (i = 0; i < size(special); i++)
      8             if (special[i] >= bottom) break;
      9         for (; i < size(special); i++) {
     10             if (special[i] > top) break;
     11             res = max(res, special[i] - bottom);
     12             bottom = special[i] + 1;
     13         }
     14 
     15         return max(res, top - bottom + 1);
     16     }
     17 };