You are viewing a single comment's thread. Return to all comments →
Ok , I figured it out, it's also the order of the operations that matters, 1st update tot, then counter3, and last counter2, so it should be instead:
tot += counter3.getOrDefault(elem, 0l); if (counter2.containsKey(elem)) { counter3.put(elem * r, counter3.getOrDefault(elem * r, 0L) + counter2.get(elem)); } counter2.put(elem * r, counter2.getOrDefault(elem * r, 0l) +1l);
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 →
Ok , I figured it out, it's also the order of the operations that matters, 1st update tot, then counter3, and last counter2, so it should be instead: