首页 > 其他 > 详细

leetcode-163周赛-1261-在污染的二叉树中查找元素

时间:2019-11-20 12:01:02      阅读:75      评论:0      收藏:0      [点我收藏+]

题目描述:

技术分享图片

 

技术分享图片

 

 技术分享图片

 

 方法一:

class FindElements:

    def __init__(self, root: TreeNode):
        self.d = set()
        def f(r, x):
            if r:
                self.d.add(x)
          r.val = x f(r.left,
2 * x + 1) f(r.right, 2 * x + 2) f(root, 0) def find(self, target: int) -> bool: return target in self.d

 

 

技术分享图片

leetcode-163周赛-1261-在污染的二叉树中查找元素

原文:https://www.cnblogs.com/oldby/p/11896555.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!