Check if All the Integers in a Range Are Covered LeetCode solution in C++
1class Solution {2public:3bool isCovered(vector<vector<int>> &ranges, int left, int right) {4int n = ranges.size();56sort(ranges.begin(), ranges.end());78if (left < ranges[0][0]) // BASE CASE9return false;1011bool ans = false;1213for (int i = 0; i < n; i++) {14if (left >= ranges[i][0] && left <= ranges[i][1]) {15left = ranges[i][1] + 1;16}17if (left > right) {18ans = true;19break;20}21}22return ans;23}24};