[BOJ] Cow LandRead more
[BOJ] Milk VisitsRead more
[BOJ] DisruptionRead more
[BOJ] 트리와 쿼리 3Read more
[BOJ] LCA 2Read more
[BOJ] 트리와 쿼리 10Read more
[BOJ] 국제 메시 기구Read more
[AtCoder] E - Colorful SubsequenceRead more
[AtCoder] F - Many LampsRead more
[LeetCode] Count Good Triplets

1534. Count Good Triplets

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.

Read more