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

  • 1

    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.

  • 0

    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.