You are viewing a single comment's thread. Return to all comments →
Hey, guys Here is a solution based on modular arithmetic for the case when k > n:
new_index = (n + i - abs(k-n)) % n
(note: n - abs(k-n) can be collapsed to a single number)
Seems like cookies are disabled on this browser, please enable them to open this website
Arrays: Left Rotation
You are viewing a single comment's thread. Return to all comments →
Hey, guys
Here is a solution based on modular arithmetic for the case when k > n:
(note: n - abs(k-n) can be collapsed to a single number)