1534. Count Good Triplets
Содержание
class Solution:
def countGoodTriplets(self, arr: List[int], a: int, b: int, c: int) -> int:
res, n = 0, len(arr)
for i in range(n):
for j in range(i + 1, n):
for k in range(j + 1, n):
res += (
abs(arr[i] - arr[j]) <= a
and abs(arr[j] - arr[k]) <= b
and abs(arr[i] - arr[k]) <= c
)
return res