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.
Thanks for C_jain and Mikelane's explanation. Since this issue has been a long time in the repo. I was confused at initial attempts to resolve the problem and did some research for this kind of distribution on a cyclic list. I think most of us can figure out mod opertation should be used but still confused why some test cases can pass and others not. The key part is that indexing system are different between mod (0-based indexing) and candy distribution, or any counting in our real life(1-based indexing). So basically, any resoltuion can work as long as it deals with mod on candies and positions twice or turning indexing to 0 and mod once and turning back to 1-indexagain.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Save the Prisoner!
You are viewing a single comment's thread. Return to all comments →
Thanks for C_jain and Mikelane's explanation. Since this issue has been a long time in the repo. I was confused at initial attempts to resolve the problem and did some research for this kind of distribution on a cyclic list. I think most of us can figure out mod opertation should be used but still confused why some test cases can pass and others not. The key part is that indexing system are different between mod (0-based indexing) and candy distribution, or any counting in our real life(1-based indexing). So basically, any resoltuion can work as long as it deals with mod on candies and positions twice or turning indexing to 0 and mod once and turning back to 1-indexagain.