Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding
Ninjas X Naukri.com

Problem of the day

You are given an array 'ARR' of distinct positive integers. You need to find all numbers that are in the range of the elements of the array, but not in the array. The missing elements should be printed in sorted order.

```
If the given array is [4, 2, 9] then you should print "3 5 6 7 8". As all these elements lie in the range but not present in the array.
```

Detailed explanation

```
1 <= T <= 10
1 <= N <= 10^5
0 <= 'ARR[i]' <= 150000
Where 'ARR[i]' denotes the array element.
Time Limit: 1 sec
```

```
2
4
1 2 4 6
3
1 2 3
```

```
3 5
[Blank]
```

```
In test case 1, As only 3 and 5 are not in the array and both lie in the range of the array. Thus answer would be "3 5" i.e sorted order.
In test case 2, Since all the elements are present from 1 to 3, the empty list is returned as a answer.
```

```
2
3
7 4 9
4
3 6 7 4
```

```
3 5 6 8
5
```

```
In test case 1, As only 3, 5, 6 and 8 are not in the array and lie in the range of the array. Thus answer would be "3 5 6 8" i.e sorted order.
In test case 2, As only 5 is not in the array and lie in the range of the array. Thus answer would be "5".
```