Java beats 100%, 1ms
Time Complexity O(n^2)\nSpace Complecity O(1)\n\n\npublic int numTeams(int[] rating) {\n\tint n = rating.length;\n    int ans = 0;\n    \n    for(int i=0; i<n; 
Time Complexity O(n^2)\nSpace Complecity O(1)\n\n```\npublic int numTeams(int[] rating) {\n\tint n = rating.length;\n    int ans = 0;\n    \n    for(int i=0; i<n; i++) {\n        int l = 0;\n        int r = 0;\n        \n        for(int j=0; j<i; j++) {\n            if (rating[j] < rating[i]) l++;\n        }\n        \n        for(int k=i+1; k<n; k++) {\n            if (rating[i] < rating[k]) r++;\n        }   \n\t\t\n        ans += (l*r) + (i-l)*(n - i - r - 1);\n    }\n\n    return ans;\n }\n```
['Java']