C++/Python, sorting solution with explanation
First, we sort ranges by where it start,\nand merge overlapped ranges into a range,\nthen calculate how many way to organize group1 from this merged ranges,\nju
First, we sort ranges by where it start,\nand merge overlapped ranges into a range,\nthen calculate how many way to organize group1 from this merged ranges,\njust power of 2, 2^cnt.\n\ntc is O(nlogn), sc is O(1).\n\n### python\n```python\nclass Solution:\n    def countWays(self, ranges: List[List[int]]) -> int:\n        cnt = 1\n        ranges.sort()\n        left, right = ranges[0]\n        for x, y in ranges:\n            if x > right:\n                cnt += 1\n                left, right = x, y\n            else: right = max(right, y)\n        return pow(2, cnt, int(1e9+7))\n```\n### c++\n```cpp\nconst int MOD = 1e9+7;\nclass Solution {\npublic:\n    int countWays(vector<vector<int>>& ranges) {\n        sort(ranges.begin(), ranges.end());\n        int ans = 2, left = ranges[0][0], right = ranges[0][1];\n        for (auto& x: ranges) {\n            if (x[0] > right) {\n                left = x[0], right = x[1];\n                ans = (ans * 2) % MOD;\n            } else right = max(right, x[1]);\n        }\n        return ans;\n    }\n};\n```
['C', 'Sorting', 'Python']