Valid BST Permutations

Company: Oracle_27thjuly

Difficulty: medium

Problem Statement

Valid BST Permutations A binary tree is a data structure characterized by the following properties: It can be an empty tree, where root = null . It can consist of a root node that contains a value and two sub-trees labeled "left" and "right". Each sub-tree also follows the definition of a binary tree. A binary tree is a binary search tree (BST) if all the non-empty nodes follow these two rules: If a node has a left sub-tree, then all the values in its left sub-tree are smaller than its value. If a node has a right sub-tree, then all the values in its right sub-tree are greater than its value. You are given n query values. For each query value k , determine the number of structurally distinct BSTs that can be created using nodes numbered 1 to k (inclusive), modulo 100000007 (10^8 + 7) . Function Description Complete the function numBST in the editor below. numBST has the following parameter(s): int nodeValues[n] : the query values to analyze. Returns int[n] : the num