C++ || Easy Video Solution
The video solution for the below code is\nhttps://youtu.be/e6_F4VMr6XU\n\n# Code\n\nclass Solution {\npublic:\n    int numTeams(vector<int>& rating) {\n        
The video solution for the below code is\nhttps://youtu.be/e6_F4VMr6XU\n\n# Code\n```\nclass Solution {\npublic:\n    int numTeams(vector<int>& rating) {\n        // 2 5 3 4 1\n        // Condition - 1\n        // 2 3 4\n        // Condition - 2\n        // 5 3 1\n        // 5 4 1\n        // Smallest numbers and largest numbers\n        // Rating   : 2 5 3 4 1  // x 3 4 - 1\n        // Smallest : 0 1 1 2 0  // x 3 1 - 1\n        // Largest  : 0 0 1 1 4  // x 4 1 - 1\n        int n = rating.size();\n        vector<int> smallest(n, 0);\n        vector<int> largest(n, 0);\n        for(int i = 0 ; i < n ; i++){\n            for(int j = i - 1 ; j >= 0 ; j--){\n                if(rating[i] > rating[j]) smallest[i]++;\n                if(rating[i] < rating[j]) largest[i]++;\n            }\n        }\n        int ans = 0;\n        for(int i = 0 ; i < n ; i++){\n            for(int j = i - 1 ; j >= 0 ; j--){\n                if(rating[i] > rating[j]) ans += smallest[j];\n                if(rating[i] < rating[j]) ans += largest[j];\n            }\n        }\n        return ans;\n    }\n};\n```
['C++']