• + 0 comments

    Simple Java solution without additional list

       int size = a.size();
        k=k%size;
        List<Integer> res = new ArrayList<>();
        for(int i:queries){
            int idx = i-k;
            if(idx<0) idx+=size;
            res.add(a.get(idx));
        }
        return res;