forked from codehouseindia/Java-Programs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathleft rotation
More file actions
37 lines (31 loc) · 861 Bytes
/
left rotation
File metadata and controls
37 lines (31 loc) · 861 Bytes
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
#https://www.facebook.com/permalink.php?story_fbid=103039851600105&id=100056822710327
#Subscribed by Sonali Gupta
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static void main(String[] args) {
Scanner in =new Scanner(System.in);
int n = in.nextInt();
int d = in.nextInt();
int[] arr=new int[n];
int i, temp, j;
for(i=0;i<n;i++)
arr[i]=in.nextInt();
for (i = 0; i < d; i++)
{
temp = arr[0];
for(j = 1; j <= n-1; j++)
{
arr[j-1] = arr[j];
}
arr[n-1] = temp;
}
for(i = 0; i < n; i++)
{
System.out.print(arr[i]+" ");
}
}
}