You are viewing a single comment's thread. Return to all comments →
Easy to understand Python code
from collections import Counter, defaultdict def countTriplets(arr, r): left = defaultdict(int) right = Counter(arr) res = 0 for a in arr: right[a] -= 1 cl = left[a/r] cr = right[a * r] res += cl * cr left[a] += 1 return res
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 →
Easy to understand Python code