Because you sort the array you may have values such that the indices are in
the wrong order e.g your 'end' position is less than your 'start' position.
You need to check for this, however if you use an inplace sorting algorithm
this becomes easier. Additionally you may have up to O(n^2) occurrences
so when you say 'now check for consecutive value which have same value' you
should do a binary search for the end position instead. If you do as you
said you may take O(n) per search. You want to report the ranges to avoid
having to have report each occurrence.

On 18 September 2012 05:11, pankajsingh <[email protected]> wrote:

> it wud give u continuous...subarray...if u want non continuous..question
> shud be subsequence...and for that u need to all combination O(n^20..which
> is offcourse bruteforce...
>
> --
> 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