You are viewing a single comment's thread. Return to all comments →
can someone please help me understand the problem with my code??
def countTriplets(arr, r): d = defaultdict(int) count = 0 for i in arr: d[i] += 1 for i in d: if i == i*r and i == i*r*r: count = count + (d[i] * (d[i]-1) * (d[i] - 2)) // 6 else: if i*r in d and i*r*r in d: count = count + d[i] * d[i*r] * d[i*r*r] 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 →
can someone please help me understand the problem with my code??