Merge Intervals + Modular Exponentiation | C++
\nclass Solution {\n    int power(int x, int n, int mod) {\n        long long ans = 1;\n        while(n) {\n            if(n % 2) ans = (ans * x) % mod;\n      
```\nclass Solution {\n    int power(int x, int n, int mod) {\n        long long ans = 1;\n        while(n) {\n            if(n % 2) ans = (ans * x) % mod;\n            x = (x * x) % mod;\n            n /= 2;\n        }\n        return ans;\n    }\npublic:\n    int countWays(vector<vector<int>>& ranges) {\n        vector<vector<int>> merged;\n        sort(ranges.begin(), ranges.end());\n        merged.push_back(ranges[0]);\n        \n        for(int i=1; i<ranges.size(); i++) {\n            if(merged.back()[1] >= ranges[i][0]){\n                merged.back()[1] = max(merged.back()[1], ranges[i][1]);\n            }\n            else merged.push_back(ranges[i]);\n        }\n        return power(2, merged.size(), 1e9 + 7);\n    }\n};\n```
['Sorting', 'C++']