From 4b0aad39e1d4ce166e131f7547c74d2327ffe5f6 Mon Sep 17 00:00:00 2001 From: terminaldweller Date: Thu, 16 Feb 2023 08:54:22 +0330 Subject: 104 --- 104/main.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 104/main.go (limited to '104/main.go') 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") +} -- cgit v1.2.3