MCPcopy Create free account
hub / github.com/Vishruth-S/CompetitiveCode / Solution

Class Solution

LeetCode_problems/count-good-triplets/Solution.py:12–23  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10
11# Solution:(Approach 1)
12class Solution:
13 def countGoodTriplets(self, arr: List[int], a: int, b: int, c: int) -> int:
14 n=len(arr)
15 count=0
16 for i in range(n-2):
17 for j in range(i+1,n-1):
18 if (abs(arr[i] - arr[j]) > a):
19 continue
20 for k in range(j+1,n):
21 if (abs(arr[j] - arr[k]) <= b and abs(arr[i] - arr[k]) <= c):
22 count+=1
23 return count

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected