Array with consecutive elements

Given an array of positive integers A, check and return whether the array elements are consecutive or not.

Note: Try this with O(1) extra space.



Input Format

The only argument given is the integer array A.

Output Format

Return 1 if the array elements are consecutive else return 0.

Constraints

1 <= length of the array <= 100000
1 <= A[i] <= 10^9 

For Example

Input 1:
    A = [1, 2, 3, 4, 5]
Output 1:
    1

Input 2:
    A = [5, 17, 100, 11]
Output 2:
    0
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.
Start solving Array with consecutive elements on Interview Code Editor
Hints
  • Hints are not available for this problem

Discussion


Loading...
Click here to start solving coding interview questions