C++ lis
\nclass Solution {\npublic:\n    int count(vector<int>& rating)\n    {\n        int res = 0;\n        vector<int> less(rating.size());\n        for(int i = 1; i
```\nclass Solution {\npublic:\n    int count(vector<int>& rating)\n    {\n        int res = 0;\n        vector<int> less(rating.size());\n        for(int i = 1; i < rating.size(); i++)\n        {\n            for(int j = 0; j < i; j++)\n            {\n                if(rating[j] < rating[i])\n                {\n                    less[i]++;\n                    res += less[j];\n                }\n            }\n        }\n        return res;\n    }\n    \n    int numTeams(vector<int>& rating) \n    {\n        int res = count(rating);\n        reverse(rating.begin(), rating.end());\n        return res + count(rating);\n    }\n};\n```
[]