
Consecutive Elements
Given an array arr
of N
non-negative integers, determine whether the array consists of consecutive numbers. Return true if they do, and false otherwise.
Input:
The first line of input contains a single integer T, representing the number of test cases or queries. Each test case includes two lines: The first line contains an integer 'N', the length of the array. The second line contains 'N' space-separated integers representing the elements of the array.
Output:
For each test case, print “True” or “False” in separate lines to indicate whether the elements of the array are consecutive.
Example:
Input:
T = 1
N = 3
arr = [4, 3, 5]
Output:
True
Constraints:
1 ≤ T ≤ 10
1 ≤ N ≤ 10^5
0 ≤ arr[i] < 10^9
Note:
No need to print the expected output, just implement the function logic.

Be the first one to answer
Add answer anonymously...
Top Quikr Software Developer Intern interview questions & answers
Popular interview questions of Software Developer Intern
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app