JAVA Beats 100%, Clean Code Solution
\nclass Solution {\n    public int numTeams(int[] rating) {\n        \n        int countTeams = 0;\n        \n        for (int i = 0; i < rating.length; i++) {\
```\nclass Solution {\n    public int numTeams(int[] rating) {\n        \n        int countTeams = 0;\n        \n        for (int i = 0; i < rating.length; i++) {\n            int lesserCount = 0;\n            int greaterCount = 0;\n            \n            for (int j = 0; j < i; j++) {\n                if (rating[i] > rating[j]) {\n                    ++lesserCount;\n                }\n            }\n            \n            for (int j = i + 1; j < rating.length; j++) {\n                if (rating[i] < rating[j]) {\n                    ++greaterCount;\n                }\n            }\n            \n            countTeams += lesserCount * greaterCount;\n            countTeams += (i - lesserCount) * (rating.length - 1 - i - greaterCount);\n        }\n        \n        return countTeams;\n    }\n}\n```\n\nPlease help to **UPVOTE** if this post is useful for you.\nIf you have any questions, feel free to comment below.\n**HAPPY CODING :)\nLOVE CODING :)**\n
[]