Given an integer k and queue of integers Q, write a program to reverse the order of the first k elements of the queue, leaving the other elements in the same relative order.Only following standard operations are allowed on queue.

  • enqueue(x) : Insert an item x to the rear of queue
  • dequeue() : Remove an item from front of queue
  • size() : Returns number of item in queue.
  • peek() : Get the front item.
  • empty() : Return whether the queue is empty.

Example 1

Input: Q = [10, 20, 30, 40, 50, 60, 70, 80]
       k = 5
Output: Q = [50, 40, 30, 20, 10, 60, 70, 80]

Example 2

Input: Q = [10, 20, 30, 40, 50, 60, 70, 80]
       k = 4
Output: Q = [40, 30, 20, 10, 50, 60, 70, 80]