this is just very basic triple for loop
but need to care the "continue" step cuz we dont wanna early break.
class Solution:
def countGoodTriplets(self, arr: List[int], a: int, b: int, c: int) -> int:
length = len(arr)
ans=0
for i in range(length-2):
for j in range(i+1,length-1):
if abs(arr[i]-arr[j])>a:
continue
for k in range(j+1,length):
if abs(arr[j]-arr[k])<=b and abs(arr[i]-arr[k])<=c:
ans+=1
return ans
n^3 time
1 space