You are viewing a single comment's thread. Return to all comments →
Python O(n)
def beautifulTriplets(d, arr): s=set(arr) c=0 for i in range(len(arr)-2): if arr[i]+d in s and arr[i]+2*d in s: c+=1 return c
Seems like cookies are disabled on this browser, please enable them to open this website
Beautiful Triplets
You are viewing a single comment's thread. Return to all comments →
Python O(n)