# Definition for a binary tree node.
# class TreeNode:
#     def __init__(self, x):
#         self.val = x
#         self.left = None
#         self.right = None
import functools

class Solution:
    @functools.lru_cache()
    def searchBST(self, root: TreeNode, val: int) -> TreeNode:
        if not root:
            return 
        if root.val==val:
            return root
        elif root.val<val:
            return self.searchBST(root.right,val)
        else:
            return self.searchBST(root.left,val)
        

 

相关文章:

  • 2021-11-02
  • 2022-12-23
  • 2021-05-27
  • 2022-01-27
  • 2021-08-15
  • 2022-12-23
  • 2022-12-23
  • 2022-01-02
猜你喜欢
  • 2021-08-03
  • 2022-12-23
  • 2021-05-17
  • 2022-12-23
  • 2021-06-10
  • 2022-12-23
  • 2021-12-20
相关资源
相似解决方案