my java recursive solution

  • 0
    public class Solution {
      public int maxDepth(TreeNode root) {
        if(root == null)
            return 0;
        int maxresult = max(maxDepth(root.left),maxDepth(root.right));
        return 1+maxresult;
    public int max(int a, int b)
        return a>b?a:b;


Log in to reply

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