Given an array of positive numbers arranged in any order. You have to find the length of longest continuos(difference of +1, -1) sequence in the array.
for eg. A[] = *5*, 20, 45, *3*, 98, *4*, 21, *1*, 99, *2* then longest continuos subsequence is [1, 2, 3, 4, 5] and hence the output should be *"5"*, the length of this sequence. Other Continuos sequence are - [20, 21] [45] [98, 99] [21] A[i] can be > 10^6, so hashing is not an option. Possible Approach is by sorting and time complexity will be O(nlogn). Does anyone have better approach for this ? -- Thanks and Regards, Amol Sharma -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
