@Piyush : Yes this is sorting problem .. but we have to consider many
things while sorting ..
First : if we sort the way u said, can u guarantee that it gives u optimum
value(min number of lift movements).
Second : This is not pure array problem... As the problem stated... we can
keep more than
@bharat: how do u count lift movement? Is it taking a person from any
random floor to any random floor as 1 count or the number of floor it goes
through to drop a person.
for example : if 3 1 2 is the given input. Here person 1 wants to go to
floor 3. Taking him to its respective floor counts 1 or
@subrat : its number of floors the lift moved .. its actually the distance
lift travelled ...
Ex: 312 -- person1 has to go to floor 3 -- lift has to move 2 floors --
count will be 2.
On Sun, Jun 2, 2013 at 1:04 PM, subrat kumar prasad iitr.s...@gmail.comwrote:
@bharat: how do u count lift
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