You are viewing a single comment's thread. Return to all comments →
Here is a really simple approach and its short too. Ping me if you have any questions!
def triplets(a, b, c): a = list(sorted(set(a))) b = list(sorted(set(b))) c = list(sorted(set(c))) ai = 0 bi = 0 ci = 0 ans = 0 while bi < len(b): while ai < len(a) and a[ai] <= b[bi]: ai += 1 while ci < len(c) and c[ci] <= b[bi]: ci += 1 ans += ai * ci bi += 1 return ans
Seems like cookies are disabled on this browser, please enable them to open this website
Triple sum
You are viewing a single comment's thread. Return to all comments →
Here is a really simple approach and its short too. Ping me if you have any questions!