aboutsummaryrefslogtreecommitdiffstats
path: root/104/main.go
blob: d2646d1d437aedd773059ce25741a001fdc47233 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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")
}