Missing ranges of numbers
Submissions: 3759   Accuracy:

16.85%

  Difficulty: Basic   Marks: 1

Given an array of N positive integers, print out the missing elements (if any) in the range 0 to max of Ai. If
there are more than one missing, collate them using hyphen ( - ).

Input:
The first line of input contains an integer T denoting the number of test cases. Then T test cases
follow. The first line of each test case contains a positive integer N, denoting the length of the array. The second line of each test case contains N space separated positive integers.

 

Output
Print out the range of missing numbers. If no element is missing, print "-1" (without quotes).

 

Constraints
1 <= T <= 100
0 <   N <= 10000000
0 <= Ai < 10000000

Examples:
Input
3
5
62 8 34 5 332 
4
13 0 32 500
5
2 0 9 15 999

Output
0-4 6-7 9-33 35-61 63-331
1-12 14-31 33-499
1 3-8 10-14 16-998

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

Author: Rohan Malhotra


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



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


to report an issue on this page.