Question: Program for We have N numbers, we can have multiple ranges(M) defined. We need to find the number of distinct numbers that exist in multiple
Program for We have N numbers, we can have multiple ranges(M) defined. We need to find the number of distinct numbers that exist in multiple range, and the number selected should not be selected from any other range.
For Example:- Sample Testcase1:- N=5 M=3( Number of ranges) [1,4] , [2,5] , [3,4]
Output :- 1
Sample TestCase 2:-
N=5 M=3 [1,3] , [2,4] , [3,4]
Output:-3 (We can have 1,4,5 uniquely)
Sample TestCase 3:-
N=5 M=3 [1,4] , [2,4] , [3,4]
Output - 2( We can have 4 and 5)
Constraints 1<=N<=2*10^5 1<=M<=10^5 1<=L[i] <= 10^5 1<=R[i] <=10^5
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
