题解 | #二叉树的深度# golang
二叉树的深度
http://www.nowcoder.com/practice/435fb86331474282a3499955f0a41e8b
func TreeDepth( pRoot *TreeNode ) int {
// write code here
var a,b int
if pRoot==nil {
return 0
}
a = TreeDepth(pRoot.Left)
b = TreeDepth(pRoot.Right)
return Max(a,b)+1
}
func Max(a,b int) int {
if a > b {
return a
} else {
return b
}
}
