Simple Solution of grouping together || Python
\n\n# Approach\nA question for great revision of using combinations. Treat this question as putting n distinct balls into k different boxes (2 here).\nIts k ** 
\n\n# Approach\nA question for great revision of using combinations. Treat this question as putting n distinct balls into k different boxes (2 here).\nIts k ** n\nWe know there are 2 possible groups only so k = 2.\nNow if the ranges overlap u dont need to classify them into unique balls but if they donot overlap consider them as unique ball.\nNow with above method find the number of ways they can be groupped.\n\n# Code\n```\nclass Solution:\n    def countWays(self, ranges: List[List[int]]) -> int:\n        balls = 1\n        sortedRange = sorted(ranges, key=lambda x: (x[0], x[1]))\n        lastSeenRange = sortedRange[0][1]\n        MOD = 10 ** 9 + 7\n        for i in range(1, len(sortedRange)):\n            if sortedRange[i][0] <= lastSeenRange:\n                lastSeenRange = max(lastSeenRange, sortedRange[i][1])\n            else:\n                balls += 1\n                lastSeenRange = sortedRange[i][1]\n        return (2 ** balls) % MOD\n```
['Python3']