You are viewing a single comment's thread. Return to all comments →
you could use k=k%n, what if the k is doulble or trible the size of n. subtraction always reduce one rotation.
Consider if k = 3n => k = 3n -n => k = 2n. but in case of modular it reduces to n rotation. k = 3n => k = 3n%n => k = 0.
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 →
you could use k=k%n, what if the k is doulble or trible the size of n. subtraction always reduce one rotation.
Consider if k = 3n => k = 3n -n => k = 2n. but in case of modular it reduces to n rotation. k = 3n => k = 3n%n => k = 0.