Easy & Clear Solution C++ 0ms(100%)
\nclass Solution {\npublic:\n    Solution(){\n        ios::sync_with_stdio(0); cout.tie(0); cin.tie(0);\n    }\n    int numTeams(vector<int>& rating) {\n       
```\nclass Solution {\npublic:\n    Solution(){\n        ios::sync_with_stdio(0); cout.tie(0); cin.tie(0);\n    }\n    int numTeams(vector<int>& rating) {\n        int n=rating.size(),res=0,rightLess,rightGreat,leftLess,leftGreat;\n        if(n<3)return 0;\n        for(int i=1;i<n-1;i++){\n            rightLess=0;rightGreat=0; leftLess=0; leftGreat=0;\n            for(int j=0;j<i;j++){\n                if(rating[j]<rating[i])leftLess++;\n                else leftGreat++;\n            }    \n            for(int j=i+1;j<n;j++){\n                if(rating[j]>rating[i])rightGreat++;\n                else rightLess++;\n            }\n            res=res+leftLess*rightGreat + leftGreat*rightLess;\n        }\n        return res;\n    }\n};\n```
['C', 'C++']