You are viewing a single comment's thread. Return to all comments →
Here is my Python solution!
def beautifulTriplets(d, arr): beautiful = 0 for i in range(len(arr) - 2): for j in range(i + 1, len(arr) - 1): if arr[j] - arr[i] == d: for k in range(j + 1, len(arr)): if arr[k] - arr[j] == d: beautiful += 1 return beautiful
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 →
Here is my Python solution!