Simple Recursive Approach C++ code
Intuition\nDivide and Conquer technique via recursion \n\n# Approach\nstoring left subtree in left array and right subtree in right array\ntotal number of ways 
# Intuition\nDivide and Conquer technique via recursion \n\n# Approach\nstoring left subtree in left array and right subtree in right array\ntotal number of ways can be achieved by no of arranging left subtree * no of ways of arranging right subtree * nCr\n\n\n# Code\n```\nclass Solution {\n    int mod=1e9+7;\npublic:\n    long long power(long long x,int y, int p)\n    {\n    long long res = 1; \n    x = x % p; \n    while (y > 0)\n    {\n        if (y & 1)\n            res = (res * x) % p;\n        y = y >> 1; \n        x = (x * x) % p;\n    }\n    return res;\n}\n\nlong long modInverse(unsigned long long n,int p)\n{\n    return power(n, p - 2, p);\n}\n\nlong long nCrModPFermat(long long n, int r, int p)\n{\n    if (n < r)\n        return 0;\n    if (r == 0)\n        return 1;\n     \n    long long fac[n + 1];\n    fac[0] = 1;\n    for (int i = 1; i <= n; i++)\n        fac[i] = (fac[i - 1] * i) % p;\n \n    return (fac[n] * modInverse(fac[r], p) % p\n            * modInverse(fac[n - r], p) % p)\n           % p;\n}\n    long long lrbst(vector<int>& nums){\n        int n=nums.size();\n        if(n<=2) return 1;\n        int root=nums[0];\n        vector<int> left;\n        vector<int> right;\n        for(int i=1; i<n; i++){\n            if(nums[i]<root) left.push_back(nums[i]);\n            else right.push_back(nums[i]);\n        }\n        int l=left.size();\n        int r=right.size();\n\n        long long lb=lrbst(left);\n        long long rb=lrbst(right);\n        return ((lb%mod*rb%mod)%mod*nCrModPFermat(n-1,l,mod))%mod;\n    }\n\npublic:\n    int numOfWays(vector<int>& nums) {\n        long long ans=lrbst(nums);\n        return ans-1;\n    }\n};\n```
['Math', 'Divide and Conquer', 'Binary Search Tree', 'Recursion', 'C++']