Circular Queue Rotation

Medium
queue circular rotation simulation
Problem Description

Simulate a circular queue rotation k times. After each rotation, the front element moves to the back. Report the front element after each rotation.

Input Format
First line: n k (queue size, rotations). Second line: n space-separated integers (initial queue).
Output Format
k lines, each showing the front element after that rotation.
Constraints
• 1 ≤ n ≤ 1000
• 1 ≤ k ≤ 1000
• -1000 ≤ queue elements ≤ 1000
• Rotation moves front element to back
• Report front element after each rotation
Sample Input/Output
Input:
4 3
1 2 3 4
Output:
2
3
4
Explanation

Initial: [1,2,3,4]. After rotation 1: [2,3,4,1], front=2. After rotation 2: [3,4,1,2], front=3. After rotation 3: [4,1,2,3], front=4.

Solution Hints
75
Points
2000ms
Time Limit
128MB
Memory Limit
Code Editor
Register to Submit
Register to Access Code Editor

Create a free account to solve coding problems and track your progress.

Register Now
Feedback