1534. Count Good Triplets
https://leetcode.com/problems/count-good-triplets
Description
Given an array of integers arr
, and three integers a
, b
and c
. You need to find the number of good triplets.
A triplet (arr[i], arr[j], arr[k])
is good if the following conditions are true:
0 <= i < j < k < arr.length
|arr[i] - arr[j]| <= a
|arr[j] - arr[k]| <= b
|arr[i] - arr[k]| <= c
Where |x|
denotes the absolute value of x
.
Return the number of good triplets.
Example 1:
Example 2:
Constraints:
3 <= arr.length <= 100
0 <= arr[i] <= 1000
0 <= a, b, c <= 1000
ac
Last updated