c++ merge interval
\nconstexpr int mod = 1e9 + 7;\n\nclass Solution {\npublic:\n    long long pow(long long m, long long n) {\n        if (n == 0) return 1;\n        return (((n %
```\nconstexpr int mod = 1e9 + 7;\n\nclass Solution {\npublic:\n    long long pow(long long m, long long n) {\n        if (n == 0) return 1;\n        return (((n % 2) ? m : 1) * pow(m * m % mod, n / 2)) % mod;\n    }\n\n    int countWays(vector<vector<int>>& ranges) {\n        sort(ranges.begin(), ranges.end());\n\n        auto r = ranges[0];\n        int n = 1;\n        for (int i = 1; i < ranges.size(); ++i) {\n            if (r[1] >= ranges[i][0]) {\n                r[1] = max(r[1], ranges[i][1]);\n            } else {\n                r = ranges[i], ++n;\n            }\n        }\n        return pow(2, n);        \n    }\n};\n```
[]