Java recursive programming


  • 1
    B
    public class Solution {
        public int maxDepth(TreeNode root) {
            if(root == null)
                return 0;
            int lDepth = maxDepth(root.left)  + 1;
            int rDepth = maxDepth(root.right) + 1;
            return lDepth >= rDepth? lDepth : rDepth;
        }
    }
    

Log in to reply
 

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