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