Solution to Sequence Of BST from Jobdu

12 Aug

Question (in Chinese):

Question Name: Sequence Of BST

Question Description: Give an array, check whether it is possble to be the post-order traversal result on some binary search tree.

Input: the input might contain multiple test cases. Inside each test case, the first line includes one interger N (0 <= N <= 10000), saying the size of the array. The second line includes N integers, as the value of the array.

Output: “Yes” if the array is the post-order result of some BST. Otherwise, print “No”.

The solution is:

Leave a Reply

Your email address will not be published. Required fields are marked *

Please put your code into a <pre>YOUR CODE</pre> section. Thanks and Happy Coding!