Skip to content

Commit 2759f2e

Browse files
authored
Merge pull request mayankgb2#17 from pinkpelagic/patch-2
Added Left Rotation
2 parents 191b634 + 4db2022 commit 2759f2e

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

left rotation

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#https://www.facebook.com/permalink.php?story_fbid=103039851600105&id=100056822710327
2+
#Subscribed by Sonali Gupta
3+
4+
import java.io.*;
5+
import java.util.*;
6+
import java.text.*;
7+
import java.math.*;
8+
import java.util.regex.*;
9+
10+
public class Solution {
11+
public static void main(String[] args) {
12+
Scanner in =new Scanner(System.in);
13+
int n = in.nextInt();
14+
int d = in.nextInt();
15+
int[] arr=new int[n];
16+
17+
int i, temp, j;
18+
19+
for(i=0;i<n;i++)
20+
arr[i]=in.nextInt();
21+
22+
for (i = 0; i < d; i++)
23+
{
24+
temp = arr[0];
25+
for(j = 1; j <= n-1; j++)
26+
{
27+
arr[j-1] = arr[j];
28+
}
29+
arr[n-1] = temp;
30+
}
31+
32+
for(i = 0; i < n; i++)
33+
{
34+
System.out.print(arr[i]+" ");
35+
}
36+
}
37+
}

0 commit comments

Comments
 (0)