You are given two positive integers A and B. For all permutations of [1, 2, …, A], we create a BST. Count how many of these have height B.
A = 3, B = 1 Two permutations [2, 1, 3] and [2, 3, 1] generate a BST of height 1. In both cases the BST formed is 2 / \ 1 3 Another example, A = 3, B = 2 Return 4.
Next question, can you do the problem in O(N3)?
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a question? Checkout Sample Codes for more details.