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.
Elements with a remainder of 0 mod k, are paired with elements in the SAME residue class. So, we shouldn't just multiply here because we will be overcounting. So, we need choose(m, 2), where m is the number of elements mod 0. I have implemented this logic in another way here ... https://www.hackerrank.com/challenges/divisible-sum-pairs/submissions/code/45490290
Check it out. It might help.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Divisible Sum Pairs
You are viewing a single comment's thread. Return to all comments →
Elements with a remainder of 0 mod k, are paired with elements in the SAME residue class. So, we shouldn't just multiply here because we will be overcounting. So, we need choose(m, 2), where m is the number of elements mod 0. I have implemented this logic in another way here ... https://www.hackerrank.com/challenges/divisible-sum-pairs/submissions/code/45490290
Check it out. It might help.