NewProject Coding is here — build features and fix bugs in real codebases with an AI assistantSee what's new

You are implementing a simplified elevator assignment system for a building. Each elevator is represented as an array [<floor>, <state>], where floor is a string representing the elevator's current floor (e.g., "1", "10"), and state is one of "up", "down", or "idle". The passenger's request is given as an array [<floor>, <direction>], where floor is a string for the passenger's current floor and direction is either "up" or "down".

When a passenger calls for an elevator, assign one eligible elevator to respond, following these rules:

  • An idle elevator can answer any call, regardless of floor or direction.
Test Cases
Input
Output
Expected