Is the problem assuming that values of the BST is different from each other?


  • 2
    A

    The interface function is given two pointers and the returned value is pointer ,not value. If values of the is repeated, say a extreme case: values are all the same. In general solution, root will be returned which considers only values of p, q not their positions in the BST.So I wonder if pointers should be considered.


  • 0
    Q

    You need to lookup what is BST (Binary Search Tree.) If values were repeated it wouldn't be BST, and we would not be able to use the BST properties to solve the problem quicker.


  • 0
    R

    As far as I remember, in text book, BST allows repeated values, all values on the left tree are <= root, all values on the right >= root. So, pointers should be considered.


Log in to reply
 

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