Skip to content

Commit 2352e11

Browse files
authored
Create 1534. Count Good Triplets (#767)
2 parents e4e64d7 + 1033788 commit 2352e11

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

1534. Count Good Triplets

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class Solution {
2+
public:
3+
int countGoodTriplets(vector<int>& arr, int a, int b, int c) {
4+
int ans=0;
5+
for(int i=0;i<arr.size();i++){
6+
for(int j=i+1;j<arr.size();j++){
7+
for(int k=j+1;k<arr.size();k++){
8+
if(i!=j&&j!=k&&i!=k&&abs(arr[i]-arr[j])<=a&&abs(arr[j]-arr[k])<=b&&abs(arr[k]-arr[i])<=c){
9+
ans++;
10+
}
11+
}
12+
}
13+
}
14+
return ans;
15+
}
16+
};

0 commit comments

Comments
 (0)