Example output given is wrong


#1

The output for the example given should be 0, since it is not a valid pre-order traversal of a BST. You can also check by seeing the expected output for [7, 7, 10, 10, 9, 5, 2, 8]. You will find it is indeed 0.


#2

thats right - should be 0


#3

Yes its Output Should be 0.


#4

I think it’s a valid BST, Correct me!.
|||||||| 7|||||||||
||||||7 ||||10||
|||5|||||||10|||
2||||||||9|||||||
|||||||8||||||||||


#5

But the sequence they have given doesn’t match the preorder of your BST


#6

yes, my bad!!!
It’s a wrong test case.


#7

Yeah. output should be 0.