BETA

Difficulty Level: Easy

Submissions: 270 Accuracy:

10%

Missing Intervals
       

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.

 

** For More Input/Output Examples Use 'Expected Output' option **

Author: Anushree_20

Set Default Code

					   
It is recommended to 'Compile & Test' your code before clicking 'Submit'!

Compilation/Execution Result:

Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.