public class Solution { public int findDepth(TreeNode root) { if (root == null) { return 0; } return Math.max(findDepth(root.left) + 1, findDepth(root.right) + 1); } public int maxDepth(TreeNode root) { return findDepth(root); }}
本文共 324 字,大约阅读时间需要 1 分钟。
public class Solution { public int findDepth(TreeNode root) { if (root == null) { return 0; } return Math.max(findDepth(root.left) + 1, findDepth(root.right) + 1); } public int maxDepth(TreeNode root) { return findDepth(root); }}
转载于:https://blog.51cto.com/tianyiya/2172947