所用知识 二叉树 所用语言 java 解题思路 使用递归进行深度遍历 完整代码 public int maxDepth (TreeNode root) { // write code here if (root == null) { return 0; } else { int leftHeight = maxDepth(root.left); int rightHeight = maxDepth(root.right); return Math.max(leftHeight, rightHeight) + 1; } }