Find a range that covers all the elements of given N ranges - GeeksforGeeks
Find a range that covers all the elements of given N ranges
Given N ranges containing L and R. The task is to check or find the index(0-based) of the range which covers all the other given N-1 ranges. If there is no such range, print -1.
Note: All L and R points are distinct.
Examples:
Input: L[] = {1, 2}, R[] = {1, 2}
Output: -1Input: L[] = {2, 4, 3, 1}, R[] = {4, 6, 7, 9}
Output: 3
Range at 3rd index i.e. 1 to 9 covers
all the elements of other N-1 ranges.
Read full article from Find a range that covers all the elements of given N ranges - GeeksforGeeks
No comments:
Post a Comment