Length of largest contiguous array

Question

Given an array of distinct integers, write code to find length of the longest subarray which contains numbers that can be arranged in a continuous sequence.

For example:

Input:  arr[] = {10, 12, 11};
Output: 3

Input:  arr[] = {14, 12, 11, 20};
Output: 2

Input:  arr[] = {1, 10, 23, 11, 13, 14, 15, 12, 98}
Output: 5

Solution

Access restricted

Subscribe to premium account to see the solution.

Get premium now