Skip to content

Commit e93a404

Browse files
committed
fd
1 parent d84dfa1 commit e93a404

File tree

2 files changed

+12
-0
lines changed
  • solution/src/main/java/com/inuker/solution
  • test/src/main/java/com/inuker/test

2 files changed

+12
-0
lines changed
0 Bytes
Binary file not shown.

test/src/main/java/com/inuker/test/main.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,18 @@ public static void main(String[] args) {
1818
for (Integer n : list) {
1919
System.out.print(n + " ");
2020
}
21+
}
2122

23+
public TreeNode inorderSuccessor(TreeNode root, TreeNode p) {
24+
TreeNode node = null;
25+
while (root != null) {
26+
if (p.val < root.val) {
27+
node = root;
28+
root = root.left;
29+
} else {
30+
root = root.right;
31+
}
32+
}
33+
return node;
2234
}
2335
}

0 commit comments

Comments
 (0)