Timer is Running

Check if array contains contiguous integers with duplicates allowed
Submissions: 15686   Accuracy:


  Difficulty: Easy   Marks: 2

Given an array of n integers(duplicates allowed). Print “Yes” if it is a set of contiguous integers else print “No”.

INPUT: The first line consists of an integer T i.e. the number of test cases. First line of each test case consists of an integer n, denoting the size of array. Next line consists of n spaced integers, denoting elements of array.

OUTPUT:  Print “Yes” if it is a set of contiguous integers else print “No”.




5  2  3  6  4  4  6  6
10  14  10  12  12  13  15

Output :

Test Case 1 : The elements  of array form a contiguous set of integers which is {2, 3, 4, 5, 6} so the output is Yes.
Test Case 2: We are unable to 
form contiguous set of integers using elements of array.

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

Author: Nishant_Singh

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.