169. Leetcode 968. 监控二叉树 (贪心算法-交叉类题目)
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution:
def minCameraCover(self, root: TreeNode) -> int:
result = 0
def traversal(cur):
nonlocal result
if not cur:return 2
left = traversal(cur.left)
right = traversal(cur.right)
版权声明:
作者:lichengxin
链接:https://www.techfm.club/p/26193.html
来源:TechFM
文章版权归作者所有,未经允许请勿转载。
THE END
二维码
共有 0 条评论