diff options
author | terminaldweller <thabogre@gmail.com> | 2023-02-16 05:24:22 +0000 |
---|---|---|
committer | terminaldweller <thabogre@gmail.com> | 2023-02-16 05:24:22 +0000 |
commit | 4b0aad39e1d4ce166e131f7547c74d2327ffe5f6 (patch) | |
tree | 1e6481ec1ebe44dae41977678483d62cafe20c0d | |
parent | 989 (diff) | |
download | leetcode-4b0aad39e1d4ce166e131f7547c74d2327ffe5f6.tar.gz leetcode-4b0aad39e1d4ce166e131f7547c74d2327ffe5f6.zip |
104
Diffstat (limited to '')
-rw-r--r-- | 104/go.mod | 3 | ||||
-rw-r--r-- | 104/main.go | 30 |
2 files changed, 33 insertions, 0 deletions
diff --git a/104/go.mod b/104/go.mod new file mode 100644 index 0000000..da7c5c1 --- /dev/null +++ b/104/go.mod @@ -0,0 +1,3 @@ +module 104 + +go 1.19 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") +} |