← Back to companies
[ OK ] Loaded —
[ INFO ]
$ cd
$ ls -lt
01
02
03
04
05
$ ls -lt
01
02
03
04
05
user@intervues:~/$
Practice/Google/Leetcode 1534. Count Good Triplets
CodingMust
You are given an array of integers arr and three non-negative integers a, b, and c.
Your task is to count how many triplets of indices (i, j, k) exist such that:
Return the total count of such valid triplets.
Example 1:
` Input: arr = [3, 0, 1, 1, 9, 7], a = 7, b = 2, c = 3 Output: 4 Explanation: The valid triplets are:
Example 2:
Input: arr = [1, 1, 2, 2, 3], a = 5, b = 5, c = 5 Output: 10 Explanation: With generous thresholds, all C(5,3) = 10 triplets are valid since the array values are close together.
Example 3:
Input: arr = [1, 5, 10, 15, 20], a = 1, b = 1, c = 1 Output: 0 Explanation: All consecutive differences exceed 1, so no triplet can satisfy all three constraints.