Merge Intervals | JavaScript/TypeScript Solution
Complexity\n- Time complexity: O(n*log(n))\n Add your time complexity here, e.g. O(n) \n\n# Code\n\nfunction countWays(ranges: number[][]): number {\n    ranges
# Complexity\n- Time complexity: $$O(n*log(n))$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nfunction countWays(ranges: number[][]): number {\n    ranges.sort(([a], [b]) => a - b);\n\n    let i = 1;\n    while (i < ranges.length) {\n        const [a, b] = ranges[i - 1];\n        const [c, d] = ranges[i];\n\n        if (b >= c) ranges.splice(i - 1, 2, [a, Math.max(b, d)]);\n        else i++;\n    }\n\n    let ans = 1;\n    for (let i = 0; i < ranges.length; i++) {\n        ans *= 2;\n        ans %= 1e9 + 7;\n    }\n    return ans;\n};\n```
['TypeScript']