Sort + interval merge counting: time O(n.log(n)), space O(1)
\n# Code\n\nclass Solution(object):\n    def countWays(self, ranges):\n        """\n        :type ranges: List[List[int]]\n        :rtype: int\n        """\n   
\n# Code\n```\nclass Solution(object):\n    def countWays(self, ranges):\n        """\n        :type ranges: List[List[int]]\n        :rtype: int\n        """\n        \n        # time O(n.log(n)), space O(1)\n        ranges.sort()\n        count = 0\n        prev_s, prev_e = ranges[0]\n        for i in range(1, len(ranges)):\n            cur_s, cur_e = ranges[i]\n            if prev_e < cur_s:\n                prev_s, prev_e, count = cur_s, cur_e, count+1\n            else:\n                prev_e = max(prev_e, cur_e)\n        count += 1\n        return (2**count) % (10**9 + 7)\n            \n\n```
['Python']