You are viewing a single comment's thread. Return to all comments →
We don't need to actually rotate the array. We can just use basic math to pull the entry from the original array:
int shift = n - (k % n); int index = (shift + m ) % 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 →
We don't need to actually rotate the array. We can just use basic math to pull the entry from the original array: