Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ee0e80d

Browse files
0700 二叉搜索树 部分代码更正
结果没问题,但逻辑不严谨
1 parent d2b05ae commit ee0e80d

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

‎problems/0700.二叉搜索树中的搜索.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ class Solution {
200200
if (val < root.val) root = root.left;
201201
else if (val > root.val) root = root.right;
202202
else return root;
203-
return root;
203+
return null;
204204
}
205205
}
206206
```
@@ -236,7 +236,7 @@ class Solution:
236236
if val < root.val: root = root.left
237237
elif val > root.val: root = root.right
238238
else: return root
239-
return root
239+
return None
240240
```
241241

242242

@@ -271,7 +271,7 @@ func searchBST(root *TreeNode, val int) *TreeNode {
271271
break
272272
}
273273
}
274-
return root
274+
return nil
275275
}
276276
```
277277

@@ -301,7 +301,6 @@ var searchBST = function (root, val) {
301301
return searchBST(root.left, val);
302302
if (root.val < val)
303303
return searchBST(root.right, val);
304-
return null;
305304
};
306305
```
307306

@@ -330,7 +329,7 @@ var searchBST = function (root, val) {
330329
else
331330
return root;
332331
}
333-
return root;
332+
return null;
334333
};
335334
```
336335

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /