题目:
输入一颗二叉树的根节点,求该树的深度。
解答:
1 public class Solution { 2 3 public int treeDepth(BinaryTreeNode root) { 4 if(root == null) { 5 return 0; 6 } 7 8 int left = treeDepth(root.getLchildNode()); 9 int right = treeDepth(root.getRchildNode()); 10 11 return (left > right):left+1:right+1; 12 } 13 }