CPP | Sorting + MATHS
Code
# Code
```cpp []
class Solution {
public:
    #define ll long long int
    int mod = 1000000007;
    int countWays(vector<vector<int>>& r) 
    {
        sort(r.begin(), r.end());
        // Find the count distinct sets
        int count=1,lend=r[0][1];
        for(int i=0;i<r.size();i++)
        {
            if(r[i][0]>lend)
            {
                count++;
            }
            lend=max(lend,r[i][1]);
        }
        // Answer is 2^count;
        ll res=1;
        for(int i=0;i<count;i++)
            res=(res*2)%mod;
        return res;    
    }
};
```
['C++']