示例#1
0
 static void Main(string[] args)
 {
     var t = new TreeNode(1);
     t.right = new TreeNode(2);
     t.right.right = new TreeNode(3);
     t.right.right.right = new TreeNode(4);
     MaxDepth(t);
 }
示例#2
0
 public static void Rec(TreeNode root)
 {
     if (root == null)
     {
         if (Max < Counter)
         {
             Max = Counter;
         }
         return;
     }
     Counter++;
     Rec(root.left);
     Rec(root.right);
     Counter--;
 }
示例#3
0
 public static int MaxDepth(TreeNode root)
 {
     Rec(root);
         return Max;
 }