We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
If rotation is greater than the length of the string, this line gets used. Say we have 5 as the length of the string. If the rotation given as 7, it is actually 2 and hence 7%5 == 2. If you're still unsure, try the above scenario and see how this line helps :)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Left Rotation
You are viewing a single comment's thread. Return to all comments →
If rotation is greater than the length of the string, this line gets used. Say we have 5 as the length of the string. If the rotation given as 7, it is actually 2 and hence 7%5 == 2. If you're still unsure, try the above scenario and see how this line helps :)