C# Solution because there weren't any others
Approach\nGenerates a table of all binomial coefficients to reference, then calculates the number of combinations for all subtrees with recursion. \nSame as the
# Approach\nGenerates a table of all binomial coefficients to reference, then calculates the number of combinations for all subtrees with recursion. \nSame as the editorial suggests.\n\nI first tried a solution calculating and caching factorials, but it was not fun trying to work with values as large as 35!\nThis one is better.\n\n# Code\n```\n    public class Solution\n    {\n        readonly int mod = 1000000007; //% 10^9 + 7 is requirement of problem\n        long[,] coefficientTable;\n        public int NumOfWays(int[] nums)\n        {\n            GenerateBinomialCoefficientTable(nums.Length);\n            return (NumOfWays(nums.ToList()) - 1) % mod;\n        }\n        public int NumOfWays(List<int> nums)\n        {\n            if (nums.Count <= 2)\n                return 1;\n\n            List<int> left = new List<int>();\n            List<int> right = new List<int>();\n            int root = nums[0];\n\n            for (int i = 1; i < nums.Count; i++)\n            {\n                if (nums[i] < root)\n                    left.Add(nums[i]);\n                else\n                    right.Add(nums[i]);\n            }\n\n            long waysLeft = NumOfWays(left);\n            long waysRight = NumOfWays(right);\n            long subtrees = (waysLeft * waysRight) % mod;\n            long binomialCoefficient = coefficientTable[nums.Count - 1, left.Count];\n            return (int)((binomialCoefficient * subtrees) % mod);\n        }\n        public void GenerateBinomialCoefficientTable(int size)\n        {\n            coefficientTable = new long[size, size];\n            for (int i = 0; i < size; ++i)\n            {\n                coefficientTable[i, 0] = 1;\n                coefficientTable[i, i] = 1;\n            }\n            for (int i = 2; i < size; i++)           \n                for (int j = 1; j < i; j++)                \n                    coefficientTable[i, j] = (coefficientTable[i - 1, j - 1] + coefficientTable[i - 1, j]) % mod;                            \n        }\n    }\n```
['C#']