Python Short Recursive solution 4 lines


  • 4
    I
    def inorderSuccessor(self, root, p):
        if not root: return None
        if root.val>p.val: return self.inorderSuccessor(root.left,p) or root 
        return self.inorderSuccessor(root.right,p)

Log in to reply
 

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