Skip to main content
Back to problems
Leetcode
Medium
Arrays
Simulation
Math
Elevator Requests I

Process a sequence of elevator requests and determine the elevator's movement or final state according to the given rules.

Acceptance 0%
Problem Statement

Elevator Requests I

You are given a building elevator and a sequence of requests. The elevator starts at a known floor, and each request asks the elevator to move to a target floor. Process the requests in order and simulate the elevator’s movement exactly as specified.

The task is to determine the resulting elevator behavior after handling all requests, such as the floors visited, the total movement, or the final floor/state, depending on the request rules.

This is a direct simulation problem: read the requests in order, apply the movement rules one by one, and track the elevator state carefully.

Notes

  • Requests must be handled in the given order.
  • The elevator may need to move up, move down, or remain idle.
  • If a request repeats the current floor, no movement may be needed.
  • Pay close attention to boundary conditions and any constraints on the elevator’s valid range of floors.

Input Format

The input format is intentionally generalized:

  • The first line describes the initial elevator state.
  • The remaining lines describe a list of floor requests.
  • Each request specifies a target floor and, if applicable, any additional instruction required by the problem rules.

Output Format

Return the final result required by the problem statement after all requests are processed. This may be the final floor, a movement count, or another aggregate value depending on the exact rules.

Constraints

  • Requests are processed in order.
  • Use integer arithmetic where appropriate.
  • Handle empty movement and repeated floors correctly.
  • The exact floor range and request limits depend on the original problem specification.
Examples
Sample cases returned by the problem API.

Example 1

Input

Start floor: 1
Requests: [3, 2, 5]

Output

Final floor: 5

Explanation

The elevator moves from 1 to 3, then 3 to 2, then 2 to 5. The final floor is 5.

Premium problem context

Unlock deeper context for this problem

Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.

Guided hints
Editorial and discussion links
Concept map and variants
Sign in to unlock
Track your progress
Sign in to bookmark this problem, save notes, and manage its revision plan.