Missing Intervals
Easy Accuracy: 13.08% Submissions: 1348 Points: 2

Given a sorted array A of integers  from 0 to 99 (repetition of elements allowed), output all the integer intervals missing from the given list.

Input:

First line of input consists of an integer T, denoting the number of test cases. For each test case, enter an integer N, denoting size of the integer array, followed by N space separated integers in sorted order in a new line.

Output:

For each test case, there is one line of output denoting the intervals of missing elements, arranged by hyphens and commas. In case of no missing elements i.e. N=100 and 0 to 99 present in the array in sorted order, output a null string/character.

Constraints:

1<=T<=100

1<=N<=100

0<=A[i]<=99, i is index of array from 0 to N-1


Example:

Input:

3
4
1 5 67 88
6
4 55 77 89 91 99
7
0 3 4 6 80 90 91

Output:

0,2-4,6-66,68-87,89-99
0-3,5-54,56-76,78-88,90,92-98
1-2,5,7-79,81-89,92-99

Explanation:

For single missing elements, we write them as it is. For consecutive or more differenced integers we use a hyphen in between to denote the interval and separate all the intervals by commas.

 

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.