Skip to content

Instantly share code, notes, and snippets.

@mohitkhosla01
Created October 18, 2016 07:55
Show Gist options
  • Save mohitkhosla01/1e75bb79a8bbadc68d3a211b402b26b4 to your computer and use it in GitHub Desktop.
Save mohitkhosla01/1e75bb79a8bbadc68d3a211b402b26b4 to your computer and use it in GitHub Desktop.
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