Count Good Triplets LeetCode solution in Python
1# Runtime: 1794 ms (Top 11.20%) | Memory: 13.8 MB (Top 87.90%)2class Solution:3def countGoodTriplets(self, arr: List[int], a: int, b: int, c: int) -> int:4count = 05for i in range(len(arr)):6for j in range(i + 1, len(arr)):7for k in range(j + 1, len(arr)):8if (9abs(arr[i] - arr[j]) <= a10and abs(arr[j] - arr[k]) <= b11and abs(arr[k] - arr[i]) <= c12):13count += 114return count