Tuesday, February 28, 2012

Length of Largest Subsequence

Given an array , find the length of largest sub-sequence such that if the minimum value in this sub-sequence in Min and maximum value is Max then the elements of this sub-sequence should be Min,Min+1,Min+2,…..,Max ( in any order )

Sample Input :
2 1 6 5 3 -1
Sample Output :
3
Here sub-sequence 2,1,3 is the largest one .

No comments:

Post a Comment