How to differ the constructions by preorder

  • 1

    for the preorder array [10,5,7], we may construct a tree like

              10                            10
            /     \            or          /
           5       7                     5

    the first one is an invalid bst, but the second one is valid, how to solve it?

Log in to reply

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