Skip to content

Commit def2a0f

Browse files
authored
Merge pull request #67 from InflixOP/patch1
Create #1534. Count Good Triplets.cpp
2 parents 1c34927 + a0e1744 commit def2a0f

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

#1534. Count Good Triplets.cpp

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

0 commit comments

Comments
 (0)