O[n^2] C++ solution, beats 99%
Intution is - pick the middle point. Find left side smaller and larger, find right side smaller and larger (in O[N])\n\nTotal teams for this middle point = (lef
Intution is - pick the middle point. Find left side smaller and larger, find right side smaller and larger (in O[N])\n\nTotal teams for this middle point = (left_side_smaller * right_side_bigger + \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t   left_side_bigger * right_side_smaller)\n\n\n\n```class Solution {\npublic:\n    int numTeams(vector<int>& rating) {\n        int i, j, k;\n        int teams = 0;\n        \n        for (j = 1 ; j < rating.size() - 1 ; j++) {\n            int left_side_smaller = 0;\n            int left_side_bigger = 0;\n            int right_side_smaller = 0;\n            int right_side_bigger = 0;\n            \n            for (i = 0; i < j; i++) {\n                if (rating[i] < rating[j]) {\n                    left_side_smaller++ ; \n                } else {\n                    left_side_bigger++ ;\n                }\n            }\n            \n            for (k = j+1 ; k < rating.size(); k++) {\n                \n                \n                if (rating[k] < rating[j]) {\n                    \n                    right_side_smaller++;\n                } else {\n                    right_side_bigger++;\n                }\n            }\n            \n            teams += (left_side_smaller * right_side_bigger + \n                      left_side_bigger * right_side_smaller);\n        }\n            \n        \n        \n        return teams;\n    }\n};
[]