Created
February 21, 2018 08:53
-
-
Save visparashar/859e93b6396886e6dfec5265e19ae2ed to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RotationArrayDemo { | |
public static void main(String[] args) { | |
int[] a ={1,2,3,4,5,6}; | |
int d =2; | |
int temp[] =new int[d]; | |
for(int i =0;i<a.length;i++){ | |
if(i<d){ | |
temp[i] =a[i]; | |
}else{ | |
a[i-d] =a[i]; | |
} | |
} | |
for(int i =0;i<d;i++){ | |
a[a.length-d+i] =temp[i]; | |
} | |
for(int i =0;i<a.length;i++){ | |
System.out.println(a[i]); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment