/**
* @author yitiaoIT
*/
class Solution {
int maxd=0;
public int diameterOfBinaryTree(TreeNode root) {
depth(root);
return maxd;
}
public int depth(TreeNode node){
if(node==null){
return 0;
}
int Left = depth(node.left);
int Right = depth(node.right);
maxd=Math.max(Left+Right,maxd);//将每個節點最大直徑(左子樹深度+右子樹深度)目前最大值比較并取大者
return Math.max(Left,Right)+1;//傳回節點深度
}
}