File tree
Expand file treeCollapse file tree1 file changed
+20
-0
lines changed Expand file treeCollapse file tree1 file changed
+20
-0
lines changed Original file line number | Diff line number | Diff line change |
---|
|
| 1 | +var countGoodTriplets = function(arr, a, b, c) { |
| 2 | +let goodTriplets = 0; |
| 3 | +const length = arr.length; |
| 4 | + |
| 5 | +for (let i = 0; i < length; i++) { |
| 6 | +for (let j = i + 1; j < length; j++) { |
| 7 | +if (Math.abs(arr[i] - arr[j]) <= a) { |
| 8 | +for (let k = j + 1; k < length; k++) { |
| 9 | +if (Math.abs(arr[j] - arr[k]) <= b && |
| 10 | +Math.abs(arr[i] - arr[k]) <= c) { |
| 11 | +goodTriplets++; |
| 12 | +// 🥋 Rock Lee: "No secret powers—just structured hustle!" 🧱 |
| 13 | +} |
| 14 | +} |
| 15 | +} |
| 16 | +} |
| 17 | +} |
| 18 | + |
| 19 | +return goodTriplets; |
| 20 | +}; |
You can’t perform that action at this time.
0 commit comments