Skip to content

Commit 5cef50b

Browse files
committed
Update inorder-successor-in-bst.cpp
1 parent a55f623 commit 5cef50b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

C++/inorder-successor-in-bst.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Solution {
1414
public:
1515
TreeNode* inorderSuccessor(TreeNode* root, TreeNode* p) {
1616
// If it has right subtree.
17-
if (p->right) {
17+
if (p && p->right) {
1818
p = p->right;
1919
while (p->left) {
2020
p = p->left;

0 commit comments

Comments
 (0)