You are given an integer n representing the total number of floors in a building, where floors are indexed from n requests.
An elevator begins at floor requests in the given order. Moving between any two floors takes an amount of time equal to the absolute difference between their floor numbers.
Return the total time required to complete all requests.
Constraints:
n
requests.length
requests[i] n
You are given an integer n representing the total number of floors in a building, where floors are indexed from n requests.
An elevator begins at floor requests in the given order. Moving between any two floors takes an amount of time equal to the absolute difference between their floor numbers.
Return the total time required to complete all requests.
Constraints:
n
requests.length
requests[i] n