We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d9d9883 commit 832bf14Copy full SHA for 832bf14
1 file changed
leetcode/700/solution.py
@@ -0,0 +1,25 @@
1
+# Definition for a binary tree node.
2
+# class TreeNode:
3
+# def __init__(self, x):
4
+# self.val = x
5
+# self.left = None
6
+# self.right = None
7
+class Solution:
8
+ def searchBST(self, root: TreeNode, val: int) -> TreeNode:
9
+ if root is None:
10
+ return root
11
+
12
+ if root.val == val:
13
14
15
+ if root.left is not None:
16
+ node = self.searchBST(root.left, val)
17
+ if node:
18
+ return node
19
20
+ if root.right is not None:
21
+ node = self.searchBST(root.right, val)
22
23
24
25
+ return None
0 commit comments