24. Reverse the First K Items of a Queue
EasyQueues
A queue is given as an array whose index 0 is the front. Reverse the order of the first k items and keep the rest in their original order. Return the resulting queue as an array, front first.
Use only queue operations (remove from the front, add to the back) and one stack.
Example 1
Input: queue = [1, 2, 3, 4, 5], k = 3 Output: [3, 2, 1, 4, 5]
Constraints
0 ≤ k ≤ queue.length ≤ 10⁵