Python 3   ||   5 lines,  w/ example   ||   T/S: 85% / 84%
\nclass Solution:\n    def countWays(self, ranges: List[List[int]]) -> int:\n\n        mx, count = -1, 0\n\n        for beg, end in sorted(ranges):\n           
```\nclass Solution:\n    def countWays(self, ranges: List[List[int]]) -> int:\n\n        mx, count = -1, 0\n\n        for beg, end in sorted(ranges):\n            count+= (beg > mx)\n            mx = max(end, mx)\n\n        return pow(2, count, 1_000_000_007)\n```\n[https://leetcode.com/problems/count-ways-to-group-overlapping-ranges/submissions/1294893645/](https://leetcode.com/problems/count-ways-to-group-overlapping-ranges/submissions/1294893645/)\n\nI could be wrong, but I think that time complexity is *O*(*N* log *N*) and space complexity is *O*(1), in which *N* ~ `len(ranges)`.\n\n
['Python3']