Given an array of integers, find largest sub-array formed by consecutive integers. The sub-array should contain all distinct values. Return the sub-array.

When the solution is called with the following input `arr = [2, 0, 2, 1, 4, 3, 1, 0]`

it is expected to return the array `[0, 2, 1, 4, 3]`

.

Starting from the index 1, we can observe the sequence of numbers 0, 2, 1, 4 and 3. When sorted, these integers create a consecutive serie with the length of 5.

Contributed by Murat Sütunç

You are not signed in. You can only run/submit code after signing in. Create your free Codela account now!