[Google | Onsite | What's the least amount of distance the elevator has to travel?]
Anonymous User
484

Was asked this but couldn't solve it. Wonder if it's a DP question?

Give you two arrays representing an elevator problem, One array represents the weight of each person, the second one represents the floor they looking to reach,
for example:
[60, 20, 80, 180, 60]
and
[2, 2, 3, 3, 5]
And the maximum weight the elevator can carry: for this problem, use 200
Question: what's the least amount of distance the elevator has to travel? (From floor 1 to floor 2, distance would be 2-1=1)
Assume everyone starts on the first floor, and the elevator has to come back to the first floor to pick up every group.
Assume people can skip the line. ie. 80 can go before 60 and 20.

Comments (5)