Created
October 18, 2016 07:55
-
-
Save mohitkhosla01/1e75bb79a8bbadc68d3a211b402b26b4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import java.util.Scanner; | |
public class circularArrayRotation { | |
public static void main(String[] args) { | |
Scanner sc=new Scanner(System.in); | |
int n=sc.nextInt(); | |
int k=sc.nextInt(); | |
int q=sc.nextInt(); | |
k%=n; | |
int []a=new int[n]; | |
for(int i=0;i<n;++i){ | |
a[(i+k)%n]=sc.nextInt(); | |
} | |
for(int i=0;i<q;++i){ | |
int m=sc.nextInt(); | |
System.out.println(a[m]); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment