1 2 3 4 5 6 7 8 9 10 11 12 13
| class Solution { public: bool isCovered(vector<vector<int>>& ranges, int left, int right) { int n = ranges.size(), s = 0; int diff[52] = {0}; for (auto &r : ranges) ++diff[r[0]], --diff[r[1] + 1]; for (int i = 1; i < left; ++i) s += diff[i]; for (int i = left; i <= right; ++i) if ((s += diff[i]) == 0) return false; return true; } };
|