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

Function equalTrees

subtree_of_another_tree_572/solution.go:25–37  ·  view source on GitHub ↗
(t1, t2 *TreeNode)

Source from the content-addressed store, hash-verified

23}
24
25func equalTrees(t1, t2 *TreeNode) bool {
26 if (t1 == nil && t2 != nil) || (t1 != nil && t2 == nil) {
27 return false
28 }
29
30 if t1 == nil && t2 == nil {
31 return true
32 }
33
34 return t1.Val == t2.Val &&
35 equalTrees(t1.Left, t2.Left) &&
36 equalTrees(t1.Right, t2.Right)
37}

Callers 1

isSubtreeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected