0510. Inorder Successor in BST II
Description
class Node {
public int val;
public Node left;
public Node right;
public Node parent;
}ac
Last updated
class Node {
public int val;
public Node left;
public Node right;
public Node parent;
}Last updated
**Input:** tree = [2,1,3], node = 1
**Output:** 2
**Explanation:** 1's in-order successor node is 2. Note that both the node and the return value is of Node type.**Input:** tree = [5,3,6,2,4,null,null,1], node = 6
**Output:** null
**Explanation:** There is no in-order successor of the current node, so the answer is null.**Input:** tree = [15,6,18,3,7,17,20,2,4,null,13,null,null,null,null,null,null,null,null,9], node = 15
**Output:** 17**Input:** tree = [15,6,18,3,7,17,20,2,4,null,13,null,null,null,null,null,null,null,null,9], node = 13
**Output:** 15**Input:** tree = [0], node = 0
**Output:** null