I am getting wrong answer for the question fun with rotation

import java.io.;
import java.util.
;
class rot
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int no=sc.nextInt();
int test=sc.nextInt();
int num[]=new int[no];
int temp[]=new int[no];
for(int i=0;i<no;i++)
num[i]=sc.nextInt();
for(int i=0;i<test;i++)
{
String pot1=sc.next();
char x[]=pot1.toCharArray();
char pot=x[0];
int val=sc.nextInt();
if(pot==‘R’)
System.out.println(num[val-1]);
else if(pot==‘C’)
{
if(val!=no)
{
System.arraycopy(num,val,temp,0,no-val);
System.arraycopy(num,0,temp,no-val,val);
num=temp;
}
}
else if(pot==‘A’)
{
if(val!=no)
{
System.arraycopy(num,no-val,temp,0,val);
System.arraycopy(num,0,temp,val,no-val);
num=temp;
}
}
}
}
}

Try this input:

3 11
1 2 3
R 1
R 2
R 3
C 1
R 1
R 2
R 3
A 2
R 1
R 2
R 3

your program prints

3
1
3

as last 3 numbers…

But I think, your next problem will be TLE…

Try providing link to the question so that others will know what the question is.

1 Like

One can easily find in user’s submitions typically, but I agree it’s polite to provide both - link to problem + link to submission…