二叉树104、二叉树的最大深度

    技术2022-07-10  148

    题目

    C#代码

    /** * Definition for a binary tree node. * public class TreeNode { * public int val; * public TreeNode left; * public TreeNode right; * public TreeNode(int x) { val = x; } * } */ public class Solution { public int MaxDepth(TreeNode root) { if(root==null) return 0; int z=MaxDepth(root.left)+1; int y=MaxDepth(root.right)+1; return z>y?z:y; } }
    Processed: 0.012, SQL: 9