Merge the ranges and count number of ways to divide n objects into two groups
Code
# Code
```cpp []
class Solution {
public:
    int countWays(vector<vector<int>>& ranges) {
        int res = 1, mod = 1e9 + 7, prev = -1;
        sort(ranges.begin(), ranges.end(), [](const auto& a, const auto& b) { 
                return a[0] < b[0]; 
        });
        for (const auto& range : ranges) {
            if (range[0] > prev) {
                res = (res * 2) % mod;
            }
            prev = max(prev, range[1]);
        }
        return res;
    }
};
```
['C++']