[C++] O(N^2) Solution | Easy Combinatorics
\nclass Solution {\npublic:\n    int numTeams(vector<int>& rating) {\n        int ans = 0;\n        for(int i=1;i<rating.size()-1;++i){\n            int l=0,r=0
```\nclass Solution {\npublic:\n    int numTeams(vector<int>& rating) {\n        int ans = 0;\n        for(int i=1;i<rating.size()-1;++i){\n            int l=0,r=0;\n            for(int j=0;j<i;++j)\n                if(rating[j]<rating[i]) l++;\n            for(int j=i+1;j<rating.size();++j)\n                if(rating[j]>rating[i]) r++;\n            ans += l*r+(i-l)*(rating.size()-i-r-1);\n        }\n        return ans;\n    }\n};\n```
['C', 'C++']