C++ Solution - Intervals - O(nlogn)
IntuitionThis is an intervals schedule, so always sort the intervals by starting time. An interval is overlapping if the stored interval's high is bigger than o
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
This is an intervals schedule, so always sort the intervals by starting time. An interval is overlapping if the stored interval's high is bigger than or equal to the current interval we're looking at, then they're overlapping.

# Approach
<!-- Describe your approach to solving the problem. -->
Using our intuition from above, if we find an overlapping range, then we want to find the max high between the two. This will be our new merged range. If they're not overlapping, we multiply the answer by 2 (2^n, where n is the amount of intervals). Then modulo to ensure the answer is within range.

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
$$O(nlogn)$$ because we're sorting the intervals

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
$$O(1)$$ because we're only using integers as extra space. The vector only holds a pair of integers.

# Code
```cpp []
class Solution {
public:
    int countWays(vector<vector<int>>& ranges) {
        sort(ranges.begin(), ranges.end());
        int n = ranges.size();
        int modulo = 1e9+7;
        int result = 2;
        vector<int> currentInterval = ranges[0];

        for(int i = 1; i < n; i++) {
            if(currentInterval[1] >= ranges[i][0]) {
                currentInterval[1] = max(currentInterval[1], ranges[i][1]);
            } else {
                result *= 2;
                result = result%modulo;
                currentInterval = ranges[i];
            }
        }

        return result;
    }
};
```
['C++']