Python 3   ||   9 lines,  recursion   ||   T/S: 99% / 87%
\nclass Solution:\n    def numOfWays(self, nums: List[int]) -> int:\n\n        def dp(nums: List[int]) -> int:\n\n            n = len(nums)\n            if n < 
```\nclass Solution:\n    def numOfWays(self, nums: List[int]) -> int:\n\n        def dp(nums: List[int]) -> int:\n\n            n = len(nums)\n            if n < 3: return 1\n            root, left, right = nums[0], [], []\n\n            for x in nums:\n                if   x < root: left .append(x)\n                elif x > root: right.append(x)\n\n            return dp(left) * dp(right) * comb(n-1, len(left))\n\n        return (dp(nums)-1) %1_000_000_007\n```\n[https://leetcode.com/problems/number-of-ways-to-reorder-array-to-get-same-bst/submissions/1279185337/](https://leetcode.com/problems/number-of-ways-to-reorder-array-to-get-same-bst/submissions/1279185337/)\n\n
['Python3']