✔ Python3 Solution | Combination
Code\n\nclass Solution:\n    def numOfWays(self, A):\n        n = len(A)\n        mod = 10 ** 9 + 7\n        def dfs(i, l, h):\n            if h == l + 1: retur
# Code\n```\nclass Solution:\n    def numOfWays(self, A):\n        n = len(A)\n        mod = 10 ** 9 + 7\n        def dfs(i, l, h):\n            if h == l + 1: return 1\n            if l < A[i] < h:\n                return (dfs(i + 1, l, A[i]) * dfs(i + 1, A[i], h) * math.comb(h - l - 2, A[i] - l - 1)) % mod\n            return dfs(i + 1, l, h)\n        return dfs(0, 0, n + 1) - 1\n```
['Recursion', 'Combinatorics', 'Python3']