摘要:
一、深度遍历 1.员工的重要性 leetcode 690 思路:深度遍历 """ # Employee info class Employee: def __init__(self, id, importance, subordinates): # It's the unique id of eac 阅读全文
posted @ 2019-10-15 10:47
nxf_rabbit75
阅读(474)
评论(0)
推荐(0)
摘要:
一、最大深度 1.二叉树的最大深度 leetcode104 给定一个二叉树,找出其最大深度。 二叉树的深度为根节点到最远叶子节点的最长路径上的节点数。 说明: 叶子节点是指没有子节点的节点。 示例: 给定二叉树 [3,9,20,null,null,15,7], 3 / \ 9 20 / \ 15 7 阅读全文
posted @ 2019-10-15 10:08
nxf_rabbit75
阅读(2780)
评论(0)
推荐(0)
摘要:
一、数组 VS 二叉树 1.有序数组转换为二叉搜索树 思路:递归 时间复杂度O(N) 空间复杂度O(1) nums为空,return None nums非空,nums[n/2]为中间元素,根结点,nums[:mid]为左子树, nums[mid+1:]为右子树 class Solution: def 阅读全文
posted @ 2019-10-15 09:40
nxf_rabbit75
阅读(1513)
评论(0)
推荐(0)
摘要:
一、路径 1.二叉树的所有路径 leetcode 257 思路:深度遍历 # Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None 阅读全文
posted @ 2019-10-15 09:35
nxf_rabbit75
阅读(2524)
评论(0)
推荐(0)