You are viewing a single comment's thread. Return to all comments →
Brilliant solution. Helped me a tonne! Equivalent code in python:
from collections import Counter def countTriplets(arr, r): r2 = Counter() r3 = Counter() count = 0 for v in arr: if v in r3: count += r3[v] if v in r2: r3[v*r] += r2[v] r2[v*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 →
Brilliant solution. Helped me a tonne! Equivalent code in python: