You are viewing a single comment's thread. Return to all comments →
public static List circularArrayRotation(List a, int k, List queries) {
for(int i=0 ; i<k ; i++){ rotateArray(a); } List<Integer> res = new ArrayList<>(); for(int q : queries){ res.add(a.get(q)); } return res; } public static void rotateArray(List<Integer> a){ a.add(0,a.get(a.size()-1)); a.remove(a.size()-1); }
Seems like cookies are disabled on this browser, please enable them to open this website
Circular Array Rotation
You are viewing a single comment's thread. Return to all comments →
public static List circularArrayRotation(List a, int k, List queries) {