Company: IBM
Difficulty: medium
Question 1 A list of ranges contains the start and end values continuous ranges of integers. For example, [1, 4] denotes all integers in the range 1 to 4, or [1, 2, 3, 4]. Divide the ranges into 2 groups such that any 2 ranges that have at least one common integer belong to the same group. Given the list of ranges, find the number of ways to distribute these ranges into 2 groups that satisfy the constraint and each group has at least one range. Since the answer can be large, compute it 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] must belong to the same group since they have common integers 3, 4