Baseline Arrays · Easy O(n) · O(1)
A warehouse conveyor holds one parcel per slot and dispatches from the head of the line. When the night shift begins, the front parcel is moved to the tail so the remaining parcels advance one slot. Produce the queue as it looks after that single left shift.
Input: An integer n followed by an array ARR of n parcel identifiers.
Output: The array after every element has moved one position to the left, with the former head appended at the tail.
1 <= n <= 10^5-10^9 <= ARR[i] <= 10^9Input: {"n":5,"ARR":[1,2,3,4,5]}
Output: [2,3,4,5,1]
Every parcel advances one slot and the original head 1 is appended at the tail.
Input: {"n":4,"ARR":[-1,0,3,9]}
Output: [0,3,9,-1]
The shift is independent of the values, so negatives move exactly like positives.