Skip to content

Commit 6037fde

Browse files
Added solutio
1 parent 19a4c97 commit 6037fde

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

count_number_of_teams.cpp

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

0 commit comments

Comments
 (0)