The problem is an array sorting problem.
You are given an array of size N containing values 1 to N only. Sort it in
O(N).

Start from floor 1 till ith floor until you find a person on the wrong
floor, take him to his respective floor
take the guy from that floor and take him to his respective floor do it
until you reach back to ith floor.
Keep a counter, if all the N persons have been moved you are done otherwise
repeat the procedure
starting from i+1 th floor.




On Fri, May 31, 2013 at 11:51 AM, bharat b <[email protected]>wrote:

> There are N floors and N persons each one is tagged with some random
> unique number between 1 to N(represents floor number).
> We have a lift which can accommodate one person at a time. Every person is
> in some random floor.
> Initially lift is at floor 1 and all floors have single person. Problem
> here is.. we have to move the persons to their corresponding floor with
> minimum number of lift movements.
> Restriction : Lift can have at most one person at a time.
> While moving persons, at some point of time, we can keep more than one
> person at one floor.
>
> --
> 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].
>
>
>

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


Reply via email to