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;
Just to note that % in C++ only gives you the dividend. It's not the modulus like in mathematics.
ah yes- I should have specified that this was written in java. thanks
can you please describe??