Redfin interview question

Coding problem for an elevator.