Python Solution
\nclass Solution:\n    def numTeams(self, rating: List[int]) -> int:\n        if len(rating)<3: \n            return 0\n        greater = defaultdict(int)\n    
```\nclass Solution:\n    def numTeams(self, rating: List[int]) -> int:\n        if len(rating)<3: \n            return 0\n        greater = defaultdict(int)\n        lesser = defaultdict(int)\n        for i in range(len(rating)-1):\n            for j in range(i+1, len(rating)):\n                if rating[i] < rating[j]:\n                    greater[i] += 1\n                else:\n                    lesser[i] += 1\n        ans = 0\n        print(greater, lesser)\n        for i in range(len(rating)-2):\n            for j in range(i+1, len(rating)):\n                if rating[i] < rating[j]:\n                    ans+=greater[j]\n                else:\n                    ans+=lesser[j]\n        return ans\n```\n**I hope that you\'ve found this useful.**\n**In that case, please upvote. It only motivates me to write more such posts\uD83D\uDE03**\nComment below if you have any queries.
['Python']