摘要:
☆☆☆方法1:递归,需要注意二叉树退化成链表的情况,要单独处理没有左子树或没有右子树的特殊情况 方法2:BFS。二叉树层序遍历 ☆☆☆方法3:DFS class Solution { int min = Integer.MAX_VALUE; public int minDepth(TreeNode 阅读全文
摘要:
class Solution { public int maxDepth(TreeNode root) { /** * 方法1:递归 */ if (root == null) return 0; int left = maxDepth(root.left); int right = maxDepth 阅读全文