You are viewing a single comment's thread. Return to all comments →
For me the division approach is more intuitive:
def countTriplets(arr, r): r1 = Counter() r2 = Counter() count = 0 for v in arr: if v/r in r2: count += r2[v/r] if v/r in r1: r2[v] += r1[v/r] r1[v] += 1 return count
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 →
For me the division approach is more intuitive: