Problem Description
You are given a preorder traversal A, of a Binary Search Tree.
Find if it is a valid preorder traversal of a BST.
Note: Binary Search Tree by definition has distinct keys and duplicates in binary search tree are not allowed.
1 <= A[i] <= 106
1 <= |A| <= 105
First and only argument is an integer array A denoting the pre-order traversal.
Return an integer:
Input 1:
A = [7, 7, 10, 10, 9, 5, 2, 8]
Output 1:
0
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.