Simple java solution
\n\n# Complexity\n- Time complexity: O(n logn)\n\n- Space complexity: O(n) where n is the size of the range array\n\n# Code\n\n\nclass Solution {\n    public in
\n\n# Complexity\n- Time complexity: $$O(n logn)$$\n\n- Space complexity: $$O(n)$$ where n is the size of the range array\n\n# Code\n```\n\nclass Solution {\n    public int countWays(int[][] ranges) {\n        Arrays.sort(ranges, new Comparator<int[]>(){\n            public int compare(int[] a, int[] b) {\n                return a[0] - b[0];\n            }\n        });\n        List<int[]> nm = new ArrayList<>();\n        for (int[] i : ranges)\n        {\n            if(nm.isEmpty() || nm.get(nm.size()-1)[1] < i[0])\n            {\n                nm.add(i);\n            }\n            else\n            {\n                nm.get(nm.size()-1)[1] = Math.max(nm.get(nm.size()-1)[1], i[1]);\n            }\n        }\n        long m=1000000007;\n        return (int)task(2,nm.size(),m);\n    }\n    public long task(long i, long j, long p) {\n        if(j==0)\n        {\n            return 1;\n        }\n        if(j==1)\n        {\n            return i;\n        }\n        long result=task(i,j/2,p);\n        result=(result*result)%p;\n        if (j % 2 == 1) {\n            result=(result*i)%p;\n        }\n        return result;\n    }\n}\n\n```
['Java']