Array
1534. Count Good Triplets
Count "good" triplets (i<j<k) where |arr[i]−arr[j]| ≤ a, |arr[j]−arr[k]| ≤ b, and |arr[i]−arr[k]| ≤ c. With n ≤ 100 the naive O(n³) triple loop passes, but a bitset optimisation replaces the…
Loading…
Count "good" triplets (i<j<k) where |arr[i]−arr[j]| ≤ a, |arr[j]−arr[k]| ≤ b, and |arr[i]−arr[k]| ≤ c. With n ≤ 100 the naive O(n³) triple loop passes, but a bitset optimisation replaces the…
Loading…