Sort it and then scan the sorted array to find out the sequence. -> O(nlgn)

On Mon, Mar 28, 2011 at 4:50 PM, bittu <[email protected]> wrote:

> Given an unsorted array, find the longest consecutive elements
> sequence.
>
> Challenge ...Time Complexity O(n) & Space o(1)
>
> Ex: 5 7 3 4 9 10 1 15 12   Ans: will be  3 4 5 (longest with 3
> elements)
> another Example  5,12,3,13,10,9,4,6,23,8,7. The answer should be
> 3,4,5,6,7,8,9,10.
>
> Thanks
> Shashank
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to