Created
September 22, 2016 13:40
-
-
Save nichtemna/84b4bec09e7a68839597c8a7482c62b2 to your computer and use it in GitHub Desktop.
CircularRotation of array
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 CircularRotation { | |
public static void main(String[] args) { | |
Scanner scanner = new Scanner(System.in); | |
int n = scanner.nextInt(); | |
int k = scanner.nextInt(); | |
int q = scanner.nextInt(); | |
int[] array = new int[n]; | |
for (int i = 0; i < array.length; i++) { | |
array[(i + k) % array.length] = scanner.nextInt(); | |
} | |
for (int i = 0; i < q; i++) { | |
System.out.println(array[scanner.nextInt()]); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment