Is [1,2], [2,1] a valid input?


  • 1
    Z

    My recursive solution failed for this test case [1, 2], [2, 1]. The expected output is {1, 2} where 2 is the left child of 1. This violates one basic property of BST:

    The common properties of binary search trees are as follows:1

    The left subtree of a node contains only nodes with keys **less than** the node's key.
    

    http://en.wikipedia.org/wiki/Binary_search_tree


  • 0
    Z

    My bad. Didn't realize that the given binary tree may not be a BST.


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.