You are viewing a single comment's thread. Return to all comments →
public static List<Integer> circularArrayRotation(List<Integer> a, int k, List<Integer> queries) { int size = a.size(); k = k % size; List<Integer> result = new ArrayList<>(size); for (Integer index : queries) { result.add(a.get(getIndexRotate(index, k, size))); } return result; } public static int getIndexRotate(int i, int k, int n){ return ((i - k) + n) % n; }
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 →