Here is the Link of the problem which I was solving on Hackerrank:-https://www.hackerrank.com/challenges/circular-array-rotation/problem
Here is my code this code passes all the testcases except the fourth test will someone please help me what's wrong here.
public class Solution {
public static void main(String[] args) {
try(Scanner in = new Scanner(System.in)) {
int n = in.nextInt();
int k = in.nextInt();
int q = in.nextInt();
int a[] = new int[n];
for(int i = 0; i < n; i++)
a[i] = in.nextInt();
for(int i = 0; i < q; i++) {
int m = in.nextInt();
System.out.println(a[(n - k + m) % n]);
}
}
}
}