摘要: ☆☆☆方法1:递归,需要注意二叉树退化成链表的情况,要单独处理没有左子树或没有右子树的特殊情况 方法2:BFS。二叉树层序遍历 ☆☆☆方法3:DFS class Solution { int min = Integer.MAX_VALUE; public int minDepth(TreeNode 阅读全文
posted @ 2020-12-21 20:44 不学无墅_NKer 阅读(80) 评论(0) 推荐(0) 编辑
摘要: class Solution { public int maxDepth(TreeNode root) { /** * 方法1:递归 */ if (root == null) return 0; int left = maxDepth(root.left); int right = maxDepth 阅读全文
posted @ 2020-12-21 19:51 不学无墅_NKer 阅读(72) 评论(0) 推荐(0) 编辑