Clean Python 3, DFS
Straightforward DFS solution.\n\nTime: C(N, 3) = O(N ^ 3)\nSpace: O(N), deep of dfs tree.\n\nclass Solution:\n    def numTeams(self, rating: List[int]) -> int:\
Straightforward DFS solution.\n\nTime: `C(N, 3) = O(N ^ 3)`\nSpace: `O(N)`, deep of dfs tree.\n```\nclass Solution:\n    def numTeams(self, rating: List[int]) -> int:\n        def dfs(i: int, prefix: List[int], increasing: bool) -> int:\n            if len(prefix) == 3: return 1\n            if i == len(rating): return 0\n            result = 0\n            rate = rating[i]\n            if (increasing and prefix[-1] < rate) or (not increasing and prefix[-1] > rate):\n                result += dfs(i+1, prefix + [rate], increasing)\n            result += dfs(i+1, prefix, increasing)\n            return result\n\n        result = 0\n        for i in range(len(rating)):\n            result += dfs(i + 1, [rating[i]], True) + dfs(i + 1, [rating[i]], False)\n        return result\n```
[]