You are viewing a single comment's thread. Return to all comments →
In your solution, you could use another modular arithmetic, to ensure the index stays within the boundaries of the array.
queries.forEach(m => { // Modulo to stay inside the boundaries of the array console.log(arr[(n+m-k)%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 →
In your solution, you could use another modular arithmetic, to ensure the index stays within the boundaries of the array.