@Arpit: The problem is that for certain values of n, you get more than
one cycle, and the cycles are disjoint. You have to find all of the
disjoint cycles and move the elements in each one.

Dave

On Feb 28, 12:25 pm, Arpit Sood <[email protected]> wrote:
> well space complexity should be mentioned in the question then, anyway,
> start with the second element put it at its correct location(say x), then
> take x put it at its correct location, this was when you do this n-1 time,
> you will get the correct answer because it forms a cycle.
>
>
>
> On Mon, Feb 28, 2011 at 11:33 PM, bittu <[email protected]> wrote:
> > @arpit otherwise it wont b amzon quest..
> >                 space dude..space is constants
>
> > 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.- Hide quoted text -
>
> - Show quoted text -

-- 
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