leetcodeSolution to some Leetcode problems written in C++ |
git clone git://git.dimitrijedobrota.com/leetcode.git |
Log | Files | Refs | README | LICENSE |
2274.cpp (490B)
0 class Solution {
1 public:
2 int maxConsecutive(int bottom, int top, vector<int> &special) const {
3 int res = 0, i;
5 sort(begin(special), end(special));
6 for (i = 0; i < size(special); i++)
7 if (special[i] >= bottom) break;
8 for (; i < size(special); i++) {
9 if (special[i] > top) break;
10 res = max(res, special[i] - bottom);
11 bottom = special[i] + 1;
12 }
14 return max(res, top - bottom + 1);
15 }
16 };