Join Regular Classroom : Visit ClassroomTech

Coding Questions | Numberland | Codewindow.in

In Numberland, the main occupation of its citizens is to perform tasks on numbers. One such important task is finding interesting number sequences.

As per the Numberland Research institute, an interesting sequence is defined as a sequence of numbers that are consecutive, for instance: {10,11,12,13} is an interesting sequence but {2,5,8} is not. Mathematically, ni+1 = ni + 1

Now, citizens are given a set of distinct numbers to extract the length of the largest interesting sequence that can be obtained by rearranging numbers within the set.

Input Format:
Two lines.
First-line contains N, the length of the input sequence.
Second-line consists of space-separated  N numbers, representing the set of numbers that must be analyzed.

Output Format:
A single integer represents the largest sequence of consecutive numbers obtained after rearranging the set.

Constrains:
9<= N <=1000
If ki be the ith element in the sequence. 1<= ki <=2000

Example 1:
Input:

11
5 4 3 2 1 11 10 14 13 12 9

Output:
6

Example 2:
Input:
19
24 73 90 25 82 51 23 21 22

Output:
5

Solution:

Coming....
You Missed
Also Checkout