Python - simple code beats 89% + explanation
Intuition\nif [1,2] is with [2,3] and [3,4] is with [2,3] then [1,2] is with [3,4]. That\'s the key realization, code in the comment explains how to build on it
# Intuition\nif [1,2] is with [2,3] and [3,4] is with [2,3] then [1,2] is with [3,4]. That\'s the key realization, code in the comment explains how to build on it\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n"""\n0: 1 way\n1: 2 ways\n2: 2 or 4 ways\n\nIdea: union find type thing? need to keep track of how many islands there are then 2^islands (num powersers to put into first bucket) is the answer?\n\nImprovement: instead of union find should just sort the list?\n"""\n\nclass Solution:\n    def countWays(self, ranges: List[List[int]]) -> int:\n        ranges.sort()\n        islands = 0\n        last_end = -1\n        for start, end in ranges:\n            if start > last_end:\n                islands += 1\n            last_end = max(end, last_end)\n        return (2**islands) % (10**9 + 7)\n```
['Python3']