You are viewing a single comment's thread. Return to all comments →
I did this.
def countTriplets(arr, r): buf = dict() count = 0 for v in reversed(arr): v2 = v*r buf.setdefault(v, [0, 0]) if v2 in buf: count += buf[v2][1] if v2 in buf: buf[v][1] += buf[v2][0] buf[v][0] += 1 # print(v, buf, count) 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 →
I did this.