Consecutive Array Elements
Submissions: 1853   Accuracy:

41.27%

  Difficulty: Easy   Marks: 2

Given an unsorted array of numbers, write a function that test whether array consists of consecutive numbers.

Input:
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case contains an integer n denoting the size of the array. The following line contains n space separated integers forming the array.

Output:
Print "Yes" (without quotes) if array elements are consecutive.
Print "No" (without quotes) if array elemetns are non-consecutive.

Constraints:
1<=T<=10^2
1<=n<=10^5
1<=a[i]<=10^5

Example:
Input:

4
6
5 4 2 3 1 6
6
83 78 80 81 79 82
5
34 23 52 12 3
6
7 6 5 5 3 4

Output:
Yes
Yes
No
No

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

Contributor: Saksham Raj Seth
Author: saksham seth


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.