I'm trying to solve a puzzle on hackerrank (the Sherlock and Queries puzzle - http://ift.tt/1uGMdk5). After working on it for a while, I started digging around on the internet for some help. I found one post here http://ift.tt/1C38rdV that confused me. It looks as if he changes this
for (int j = 0; j < N; ++j) {
if (j % B[i] == 0)
...
}
into this
for (int j = B[i] - 1; j < N; j += B[i]) {
...
}
Can someone please explain how these two are equivalent?
Aucun commentaire:
Enregistrer un commentaire