-
Notifications
You must be signed in to change notification settings - Fork 5
/
Solution.cpp
41 lines (37 loc) · 990 Bytes
/
Solution.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <string>
#include <vector>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <tuple>
#include <deque>
#include <unordered_map>
#include <cmath>
#include <queue>
using namespace std;
class Solution {
public:
int numTeams(vector<int>& rating) {
int len = rating.size(), res = 0;
for (int i = 0; i + 2 < len; i ++) {
for ( int j = i + 1; j + 1 < len; j ++) {
if (rating[i] < rating[j]) {
int small = rating[j];
for ( int k = j + 1; k < len; k ++) {
if (rating[k] > small) res ++ ;
}
} else if (rating[i] > rating[j]) {
int large = rating[j];
for ( int k = j + 1; k < len; k ++) {
if (rating[k] < large) res ++;
}
}
}
}
return res;
}
};
int main() {
Solution a;
return 0;
}