You are viewing a single comment's thread. Return to all comments →
Amazing! Looks a bit shorter with defaultdict:
def countTriplets(arr, r): v2 = defaultdict(int) v3 = defaultdict(int) count = 0 for k in arr: count += v3[k] v3[k*r] += v2[k] v2[k*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 →
Amazing! Looks a bit shorter with defaultdict: