Java Recursive Solution


  • -1
    A

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


Log in to reply
 

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