[Amazon]Two unsorted array form same BST

Given two unsorted array, check if both will create the same bst. eg: 2, 1, 4, 0 and 2, 1, 0, 4 will both form same BST.
     2
    / \
   1   4
  /
 0
but,
2,1,4,0 and 2,0,1,4 will not.

Comments

Popular posts from this blog