[Python 3] Merge Intervals | Math
\nclass Solution:\n    def countWays(self, ranges: List[List[int]]) -> int:\n        ranges.sort()\n        res = [ranges[0]]\n        \n        for s1, e1 in r
```\nclass Solution:\n    def countWays(self, ranges: List[List[int]]) -> int:\n        ranges.sort()\n        res = [ranges[0]]\n        \n        for s1, e1 in ranges[1 : ]:\n            s2, e2 = res[-1]\n            \n            if max(s1, s2) <= min(e1, e2):\n                res[-1] = [min(s1, s2), max(e1, e2)]\n            else:\n                res.append([s1, e1])\n        \n        return pow(2, len(res), pow(10, 9) + 7)\n```
['Math', 'Python', 'Python3']