C++ Solution || Using basics
\n# Code\n\nclass Solution {\npublic:\n        long long power(long long x, long long n, long long mod) {\n        long long ans = 1;\n        x=x%mod;\n       
\n# Code\n```\nclass Solution {\npublic:\n        long long power(long long x, long long n, long long mod) {\n        long long ans = 1;\n        x=x%mod;\n        while(n) {\n            if(n % 2) ans = (ans * x) % mod;\n            x = (x * x) % mod;\n            n /= 2;\n        }\n        return ans;\n    }\n    \n    int countWays(vector<vector<int>>& ranges) {\n        // Check if the input vector is empty.\n        if (ranges.empty()) {\n            return 0;\n        }\n\n        // Sort the ranges by their start points.\n        sort(ranges.begin(), ranges.end());\n\n        // Initialize the variables.\n        int ways = 1;\n        int start = ranges[0][0];\n        int end = ranges[0][1];\n     \n        // Iterate over the ranges.\n        for (int i = 1; i < ranges.size(); i++) {\n            // If the current range overlaps with the previous range,\n            // update the end point.\n            if (end >= ranges[i][0]) {\n                end = max(end, ranges[i][1]);\n            } else {\n                // Otherwise, we need to start a new range.\n                ways++;\n                end = ranges[i][1];\n            }\n        }\n\n        // Calculate the total number of ways to cover all intervals.\n     return  power(2,ways, 1e9+7);\n\n    }\n};\n\n```
['C++']