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); } }
LeetCode - 104. 二叉树的最大深度
猜你喜欢
转载自blog.51cto.com/tianyiya/2172947
今日推荐
周排行