• + 6 comments

    i actually tried running the code in eclipse, and it is matching the expected output, expect in the last case where it doesnot return the result before enter is pressed, as when the return key is pressed the output becomes fully correct.

    here is my code----------------------

    import java.io.; import java.util.;

    public class Solution {

    public static void main(String[] args) {
        Scanner s1=new Scanner(System.in);
        int n=s1.nextInt();
        int k=s1.nextInt();
        int q=s1.nextInt();
        int a[]=new int[n];
        for(int i=0;i<n;i++)
            {
            a[i]=s1.nextInt();
        }
        for(int i=0;i<q;i++)
            {
            int m=s1.nextInt();
            System.out.println(a[(n-k+m)%n]);
        }
    }
    

    }