Python | clean DP solution O(n^2) 92 % fast
\nclass Solution:\n    def numTeams(self, rating: List[int]) -> int:\n        n = len(rating)\n        \n        up = [0] * n\n        down = [0] * n\n        \
```\nclass Solution:\n    def numTeams(self, rating: List[int]) -> int:\n        n = len(rating)\n        \n        up = [0] * n\n        down = [0] * n\n        \n        teams = 0\n        \n        for i in range(n-1, -1, -1):\n            for j in range(i+1, n):\n                if rating[i] < rating[j]:\n                    up[i] += 1\n                    teams += up[j]\n                else:\n                    down[i] += 1\n                    teams += down[j]\n        \n        return teams\n```
['Python3']