Buttercola: Leetcode: Inorder Successor in BST
Leetcode: Inorder Successor in BST
Given a binary search tree and a node in it, find the in-order successor of that node in the BST.
Note: If the given node has no in-order successor in the tree, return
Brute-force solution: O(n)null
.The most straight-forward solution is to do a in-order traversal of the BST. When we found the target node, we look for the smallest number greater than the node.
Read full article from Buttercola: Leetcode: Inorder Successor in BST
No comments:
Post a Comment