Circular Queue Simulation
Published at25 Jul 2026
Created by M Ichsanul Fadhil
Create an array of size n filled with values 0 to n-1, simulating a circular queue initialization.
Example Input & Output
Example 1
Input
0
Output
[]
Explanation
Empty
Example 2
Input
5
Output
[0,1,2,3,4]
Explanation
Size 5
Example 3
Input
3
Output
[0,1,2]
Explanation
Circular queue of size 3 with values 0..2
Example 4
Input
2
Output
[0,1]
Explanation
Size 2
Example 5
Input
1
Output
[0]
Explanation
Size 1
Algorithm Flow

Recommendation Algorithm Flow for Circular Queue Simulation
Solution Approach
Best Answers
java
class Solution {
public int[] solution(int n) {
int[] r=new int[n];
for(int i=0;i<n;i++)r[i]=i;
return r;
}
}Related Queue Challenges
Comments (0)
Join the Discussion
Share your thoughts, ask questions, or help others with this Challenge.
