秒杀/** * Definition for binary tree * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */ public class Solution { public int maxDepth(TreeNode root) { if(root==null) return 0; int h1=maxDepth(root.left); int h2=maxDepth(root.right); return h1>h2?h1+1:h2+1; } }
树的最大深度 leecode java
时间: 2024-10-06 18:44:21