MCPcopy Create free account
hub / github.com/austingebauer/go-leetcode / maxDepth

Function maxDepth

maximum_depth_of_binary_tree_104/solution.go:8–16  ·  view source on GitHub ↗
(root *TreeNode)

Source from the content-addressed store, hash-verified

6)
7
8func maxDepth(root *TreeNode) int {
9 if root == nil {
10 return 0
11 }
12
13 return int(math.Max(
14 float64(1+maxDepth(root.Left)),
15 float64(1+maxDepth(root.Right))))
16}

Callers 1

Test_maxDepthFunction · 0.85

Calls

no outgoing calls

Tested by 1

Test_maxDepthFunction · 0.68