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.
I encountered the same issue (only test case 6 failing).
The root cause issue is that integer division can give the same answer for multiple different numerators. For example, the numerators 10, 11, 12, 13, and 14 all give the same answer when dividing by 5.
For every number that you encounter, you want to keep track of the fact that you have encoutered that number.
However, only numbers that are either 1 (in the edge case that r == 1) or are cleanly divisible by r (i.e., n % r == 0) should be considered as candidates to be j or k in the triple (i, j, k).
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Count Triplets
You are viewing a single comment's thread. Return to all comments →
I encountered the same issue (only test case 6 failing). The root cause issue is that integer division can give the same answer for multiple different numerators. For example, the numerators 10, 11, 12, 13, and 14 all give the same answer when dividing by 5. For every number that you encounter, you want to keep track of the fact that you have encoutered that number. However, only numbers that are either 1 (in the edge case that r == 1) or are cleanly divisible by r (i.e., n % r == 0) should be considered as candidates to be j or k in the triple (i, j, k).