Explained - Sorting & power 2 || very simple & easy to understand solution
\n\n/*\n\n1. Count number of separate range groups (say n)\n    - To do this we can simply sort the array \n    - travese the array tracking end of a reange\n  
\n```\n/*\n\n1. Count number of separate range groups (say n)\n    - To do this we can simply sort the array \n    - travese the array tracking end of a reange\n    \n2. return answer as the 2 power n\n    - as it can be large, need to use standard power technique to calculate.\n\nFAQ: why power of 2?\nans. if we have n groups, tgen to dived them into two groups,\nwe need to think like we need to have 1group  where the question becomes if we have n number then how many ways they can be grouped together  lead to summation of all coefficients of a binomial expansion, which in turn results in power of two. \n*/\n\nclass Solution {\npublic:\n    int mod= 1000000007;\n    int power(int n){\n        if(n == 1) return 2;\n        long long t = power(n/2);\n        t = (t * t)%mod;\n        if(n%2) { return (t*2)%mod; }\n        return t;\n    }\n    int countWays(vector<vector<int>>& ranges) {\n        auto comp = [](vector<int>& a, vector<int>& b){\n            if(a[0] == b[0]) return a[1] <= b[1];\n            return a[0] < b[0];\n        };\n        sort(ranges.begin(), ranges.end(), comp);\n        int n = 1, end = ranges[0][1];\n        for(auto r: ranges){\n            if(r[0] <= end){\n                end = max(end, r[1]);\n            }else{\n                n++;\n                end = r[1];\n            }\n        }\n        return power(n);\n    }\n};\n```
['C++']