Count the number of non-overlap interval groups.
Intuition\nThe ans would be pow(2, non-overlap interval groups).\n\n# Approach\n1. sort the ranges\n2. count the non-overlap interval groups\n\n# Complexity\n- 
# Intuition\nThe ans would be pow(2, non-overlap interval groups).\n\n# Approach\n1. sort the ranges\n2. count the non-overlap interval groups\n\n# Complexity\n- Time complexity: $$O(N + M)$$\nN : the size of ranges\nM : log2 of non-overlap interval groups\n\n- Space complexity: $$(logN)$$, sorting algorithm\n\n# Code\n```\nclass Solution {\n    int mod = 1e9 + 7;\n    int modpow(int b, int e) {\n        if(e == 0) return 1;\n        else if(e == 1) return b;\n        int rtn = modpow(b, e / 2);\n        rtn = ((long)rtn * rtn) % mod;\n        return e % 2 == 1 ? (b * rtn) % mod : rtn;\n    }\npublic:\n    int countWays(vector<vector<int>>& ranges) {\n        int sz = ranges.size();\n        sort(begin(ranges), end(ranges));\n        int cnt{1}, idx{};\n        for(int i = 1; i < sz; ++i) {\n            // check if overlap with ranges[idx]\n            if(min(ranges[i][1], ranges[idx][1]) >= max(ranges[i][0], ranges[idx][0])) {\n                // merge to ranges[idx]\n                ranges[idx][1] = max(ranges[i][1], ranges[idx][1]);\n            } else {\n                cnt++;\n                idx = i;\n            }\n        }\n        return modpow(2, cnt);\n    }\n};\n```
['Two Pointers', 'C++']