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 null.
解法1: O(N) Space
最直观的方法,就是先做一遍in order, 存起来,然后找出来目标node前一个node即可。
C++
Java
解法2: O(1) Space
|
|
解法3: Iterative
|
|