c++ solution
Intuition\n Describe your first thoughts on how to solve this problem. \nWe need to find number of groups and then do pow(2,no of groups) as every \n group will
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nWe need to find number of groups and then do pow(2,no of groups) as every \n group will have 2 choices weither to go in group 1 or group2.\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n- O(nlog n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(1)\n# Code\n```\n#include <iostream>\n#include <vector>\n#include <algorithm>\nusing namespace std;\n\nclass Solution {\n#define mod 1000000007\npublic:\n\n    int countWays(vector<vector<int>>& ranges) \n    {\n        sort(ranges.begin(), ranges.end());\n        int groups = 1;\n        int s = ranges[0][0];\n        int e = ranges[0][1];\n        for (int i = 1; i < ranges.size(); i++)\n        {\n            if (e >= ranges[i][0])\n            {\n                e = max(e, ranges[i][1]);\n            }\n            else\n            {\n                s = ranges[i][0];\n                e = ranges[i][1];\n                groups++;\n            }\n        }\n        return modExp(2, groups);\n    }\n\n    long long modExp(long long base, int exp) {\n        long long result = 1;\n        while (exp > 0) {\n            if (exp % 2 == 1) {\n                result = (result * base) % mod;\n            }\n            base = (base * base) % mod;\n            exp /= 2;\n        }\n        return result;\n    }\n};\n\n\n\n```
['C++']