diff options
Diffstat (limited to '')
-rw-r--r-- | 104/main.go | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/104/main.go b/104/main.go new file mode 100644 index 0000000..d2646d1 --- /dev/null +++ b/104/main.go @@ -0,0 +1,30 @@ +package main + +import "fmt" + +type TreeNode struct { + Val int + Left *TreeNode + Right *TreeNode +} + +func max(a, b int) int { + if a > b { + return a + } + return b +} + +func maxDepth(root *TreeNode) int { + if root == nil { + return 0 + } + ldepth := maxDepth(root.Left) + rdepth := maxDepth(root.Right) + + return max(ldepth, rdepth) + 1 +} + +func main() { + fmt.Println("vim-go") +} |