-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRotation.java
38 lines (38 loc) · 839 Bytes
/
Rotation.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import java.util.*;
class J
{
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
for(int l=0;l<t;l++)
{
int n=sc.nextInt();
int b=sc.nextInt();
int a[]=new int[n];
for(int i=0;i<n;i++)
{
a[i]=sc.nextInt();
}
for(int j=0;j<b;j++)
{
int temp=a[n-1];
for(int i=n-1;i>0;i--)
{
a[i]=a[i-1];
}
a[0]=temp;
}
for(int i=0;i<n;i++)
{
if(i==n-1)
{
System.out.print(a[i]);
break;
}
System.out.print(a[i]+" ");
}
System.out.println("");
}
}
}