1 public class Solution { 2 public int maxDepth(TreeNode root) { 3 if(root==null) 4 return 0; 5 return Math.max(maxDepth(root.left),maxDepth(root.right))+1; 6 } 7 }