MCPcopy Create free account
hub / github.com/VanjaRo/LeetCode / dfs

Function dfs

tasks/98.go:36–50  ·  view source on GitHub ↗
(root, min, max *TreeNode)

Source from the content-addressed store, hash-verified

34}
35
36func dfs(root, min, max *TreeNode) bool {
37 if root == nil {
38 return true
39 }
40
41 if min != nil && root.Val <= min.Val {
42 return false
43 }
44
45 if max != nil && root.Val >= max.Val {
46 return false
47 }
48
49 return dfs(root.Left, min, root) && dfs(root.Right, root, max)
50}

Callers 3

isValidBSTFunction · 0.70
serializeMethod · 0.70
deserializeMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected