Easy method to solve it.


  • -1
    J
    public class Solution {
        public int maxDepth(TreeNode root) {
            if(root==null){
                return 0;
            }else{
                int i = maxDepth(root.left);
                int j = maxDepth(root.right);
                return (i<j)?(j+1):(i+1);
            }
        }
    }

Log in to reply
 

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