You are viewing a single comment's thread. Return to all comments →
def countTriplets(arr, r): seconds = {} thirds = {} count = 0 for i in arr: if i in thirds: count += thirds[i] if i in seconds: if i * r in thirds: thirds[i * r] += seconds[i] else: thirds[i * r] = seconds[i] if i * r in seconds: seconds[i * r] += 1 else: seconds[i * r] = 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 →