You are viewing a single comment's thread. Return to all comments →
Very simple Python3 solution!
from collections import defaultdict freq = defaultdict(int) pair = defaultdict(int) def countTriplets(arr, r): count = 0 for val in arr: if val % (r*r) == 0: count += pair[val // r] if val % r == 0: pair[val] += freq[val // r] freq[val] += 1 return count
Count Triplets
You are viewing a single comment's thread. Return to all comments →
Very simple Python3 solution!