Java 1 ms Solution


  • 0
    public class Solution {
        public int maxDepth(TreeNode root) {
            
            return helper(root,0);
           
        }
        public int helper(TreeNode root,int deep)
        {
            if(root==null)
                return deep;
            else
            return Math.max(helper(root.left,deep+1),helper(root.right,deep+1));
        }
    }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.