Company: IBM
Difficulty: medium
Question 1 A range [start, end] stands for every integer from start through end, inclusive; for instance [1, 4] represents 1, 2, 3, and 4. Two ranges are considered linked whenever they share at least one integer, and any ranges linked (directly or through a chain of shared integers) must end up in the same one of two groups. Given the full list of ranges, count how many ways they can be split between exactly two groups so that this linkage rule holds and both groups end up non-empty. Because this count can grow large, give the answer modulo (10 9 +7). Function Description Complete the function distributeRanges in the editor below. distributeRanges has the following parameter: List<List<Integer>> ranges : the ranges Returns int : the number of ways to distribute the ranges into 2 groups, modulo (10 9 +7) Constraints 1 ≤ n ≤ 10 5 0 ≤ ranges[i][j] ≤ 10 9 , where 0 ≤ i Example Consider ranges = [[1, 5], [3, 8], [10, 15], [13, 14], [20, 100]]. [1, 5] and [3, 8] are linked becau