Easy , to the point solution
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n1. Sort the Ranges: Sort the ranges by their starting points to process t
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n1. Sort the Ranges: Sort the ranges by their starting points to process them in order.\n2. Count Groups: Traverse the ranges and count distinct groups of overlapping ranges.\n3. Calculate Ways: The number of ways to assign the groups into two groups is  (2^n) mod (10^9 + 7)  , where n is the count of distinct groups.\n\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```java []\nclass Solution {\n    public int countWays(int[][] ranges) {\n        Arrays.sort(ranges, (a, b) -> Integer.compare(a[0], b[0]));\n        int pre=-1;\n        int n=0;\n        for(int[] r : ranges){\n            int s=r[0];\n            int e=r[1];\n            if(s>pre){\n                n++;\n            }\n            pre=Math.max(pre, e);\n        }\n        int ans=1;\n        while(n-->0){\n            ans=ans*2 %1000000007;\n        }\n        return ans;\n    }\n}\n```
['Sorting', 'Java']