【Leetcode】111. Minimum Depth of Binary Tree 解题报告

求树的最小深度,深度为根节点到叶子节点的长度 方法1 递归 对于某个非None节点我们返回其左右子树最小的深度,但是要注意返回的值是否为0,如果为0,其最小深度就是另外一个子树的深度 class Solution: def minDepth(self, root): """ :type root: TreeNode :rtype: int """ if ro
相关文章
相关标签/搜索