Lets make it easy. Its really easy!
\n\n# Approach\nStep 1\nWe split the array into root, leftsubtree elements, rightsubtree elements.\nA simple filter loop would do that.\n\nWhy?\n        We know
\n\n# Approach\nStep 1\nWe split the array into root, leftsubtree elements, rightsubtree elements.\nA simple filter loop would do that.\n\nWhy?\n        We know the fundamentals of Binary Search Tree.\n        1. All the elements in Left SubTree(lst) are smaller than Right SubTree(rst) elements.\n        So the ordering of those elements in the array which belong to different subtree would be independent.\n        2. Ordering of the elements in the same subtree matters and will be the same relativLY.\n    Say a, b, c belong to lst, and d, e, f belong to rst. and the root of the tree is z\n    So z, a,b,c,d,e,f will do fine and so will z, d,e,f,a,b,c.\n    z, a,d,e,f,b,c will do fine (notice the relative orders)\n    z, a,d,b,e,c,f will too be fine.\n    These two sets are independent. Hence ordering wont affect the subtree\'s invariant property.\n    Now is the time to realize why ordering affects within the same subtree? (Take pen and paper to prove;)\n\n    So the problem turns out to be Leetcode Hard -> Leetcode easy naa?\n\n    Step 2:(Recursive thinking ;) )\n    After splitting, we compute recursivel the same for left subtree and right subtree.\n    We obtain the the no of orderings possiblefrom left subtree by abstracting a leftsubtree(a subproblem) into a tree itself.\n    We obtain the the no of orderings possiblefrom right subtree by abstracting the right subtree(a subproblem) into a tree itself.\n\n\n    Step3 : Conquer your subproblems!! ;) Understand the combinatorics very carefully.\n    By Fundamental theorem of counting the total possible orderings are \n    sl = size_of_left_subtree, sr = size_of_right_subtree;\n    n  = sl + sr + 1(root) w here n is total size of the tree.    \n    table[n - 1][left_subtree_size] * left_recusrsion_result * right_recursion_result;\n    since pascal table is zero index based, ncr = table[n][r];\n    where out of n - 1 places left_subtree_size places are fixed so we choose to maintain order. And \n    left_recusrsion_result * right_recursion_result orderings can be places in such choices of arrangements.\n\n\n    Side Note: \n    To access ncr effectively, we use the pascals table and retrieve table[n + 1][r + 1]\n    If we wish to compute say 4c2 then table[5][3] would return us the computation in O(1) time.Its necessary to use O(1) time instead of O(n) by the brute force approach which involves the computation over factorials.\n\n# Complexity\n- Time complexity:\n $$O(n)$$\n\n- Space complexity:\n$$O(n)$$\n\n# Code\n```\nclass Solution {\nprivate:\n    vector<vector<long long>> table;\n    long long mod;\n    int solve(vector<int> &nums) {\n        int n = nums.size();\n        if(n <= 2) return 1;\n\n        vector<int> right, left;\n        for(int i = 1; i < n; ++i) {\n            if(nums[i] < nums[0]) left.push_back(nums[i]);\n            else right.push_back(nums[i]);\n        }  \n\n        long long left_size = left.size(), right_size = right.size();\n\n        int left_orderings = solve(left) ;\n        int right_orderings = solve(right) ;\n\n        return (((table[n - 1][left_size] * left_orderings) % mod) * right_orderings) % mod ;      \n    }\n    \npublic:\n    int numOfWays(vector<int>& nums) {  \n\n        int n = nums.size();\n        mod = 1e9 + 7;\n        for(int i = 0; i < n; ++i) {\n            vector<long long> row(i + 1, 1);\n            for(int j = 1; j < i; ++j) {\n                row[j] = (table[i - 1][j] + table[i - 1][j - 1]) % mod;                 \n            }\n            table.push_back(row);\n        }\n        \n        return solve(nums) - 1;\n    \n\n        \n    }\n};\n```
['C++']