100% || C++
Intuition
Try to merge as many groups as possible. If any non mergable intervals appears, that means there can be a division for the group. Count the total no o
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

- Try to merge as many groups as possible. If any non mergable intervals appears, that means there can be a division for the group. Count the total no of partitions possible and the answer will be 2^partitions
- 2^partiotions bcz each elements have 2 options to choose either G1 or G2


# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```cpp []
class Solution {
public:
    int power(int base,int exp,int mod){
        int result=1;
        while (exp > 0) {
            if (exp % 2 == 1) { 
                result = (1LL * result * base) % mod;
            }
            base = (1LL * base * base) % mod;
            exp /= 2;
        }
        return result;
    }
    int countWays(vector<vector<int>>& ranges) {
        sort(ranges.begin(),ranges.end());
        int n=ranges.size();

        int end=ranges[0][1];
        int i=1;
        int ways=1;

        while(i<n){
            if(end>=ranges[i][0]){ // overlapping -> Convert the overlapping ones into single one
                end=max(end,ranges[i][1]);
            }
            else{ // no overlapping 
                ways++; // can be a possible division
                end=ranges[i][1];
            }
            i++;
        }
        int ans=power(2,ways,1e9+7);
        return ans;
    }
};
```
['C++']