Tap here to switch tabs
Problem
Submissions

Problem: Count Good Triplets

med
30 min
Try to solve the Count Good Triplets problem.

Statement

Given an array of integers arr, and three integers a, b, and c, return the number of good triplets.

A triplet (arr[i], arr[j], arr[k]) is defined as good if the following conditions are satisfied:

  • 0≤i<j<k<0 \leq i < j < k < arr.length

  • ∣|arr[i] −- arr[j]∣≤| \leq a

  • ∣|arr[j] −- arr[k]∣≤| \leq b

  • ∣|arr[i] −- arr[k]∣≤| \leq c

Constraints:

  • 3≤3 \leq arr.length ≤100\leq 100

  • 0≤0 \leq arr[i] ≤1000\leq 1000

  • 0≤0 \leq a, b, c ≤1000\leq 1000

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Count Good Triplets

med
30 min
Try to solve the Count Good Triplets problem.

Statement

Given an array of integers arr, and three integers a, b, and c, return the number of good triplets.

A triplet (arr[i], arr[j], arr[k]) is defined as good if the following conditions are satisfied:

  • 0≤i<j<k<0 \leq i < j < k < arr.length

  • ∣|arr[i] −- arr[j]∣≤| \leq a

  • ∣|arr[j] −- arr[k]∣≤| \leq b

  • ∣|arr[i] −- arr[k]∣≤| \leq c

Constraints:

  • 3≤3 \leq arr.length ≤100\leq 100

  • 0≤0 \leq arr[i] ≤1000\leq 1000

  • 0≤0 \leq a, b, c ≤1000\leq 1000