mercredi 21 octobre 2020

Find the value that isn't covered by the pairs

I need help on a specific question,

Input:

int n, a, b;
cin >> n;

while(n--) {
cin >> a >> b;
}

Let's say, (a and b) is an interval: Ex: (5, 6)

So, here's my question:

Suppose we have an Input Case:

4 

2 5 6 8 7

2 5 3 1 7

2 1 3 4 9

2 40 59 86 101
  
 The correct answer for that test case above is 10, 
 since (5, 6), (8, 7), (5, 3), (1, 7), (1, 3), (4, 9), (40, 59), 
 (86, 101) = 10 [Not in any of those values].

So, 4 is the number of test cases and 2 is the pairs followed by the pairs.

How can I run through all the pairs and find out what value is not in the pairs among all pairs?

Aucun commentaire:

Enregistrer un commentaire