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.
% (modulus) gives you the remainder of division.so 4%5=4,5%5=0 likewise 6%5=1, it helps you to stay inside the limit i.e lesser than the value n (i.e till n-1) eg:if n=5 it goes from 0 to 4.try this simple mod in calc or put it in a loop you will understand.we are getting the input value to the rotated index thats why (-d).if right rotation +d.
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 →
% (modulus) gives you the remainder of division.so 4%5=4,5%5=0 likewise 6%5=1, it helps you to stay inside the limit i.e lesser than the value n (i.e till n-1) eg:if n=5 it goes from 0 to 4.try this simple mod in calc or put it in a loop you will understand.we are getting the input value to the rotated index thats why (-d).if right rotation +d.