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

Function isSym

symmetric_tree_101/solution.go:22–35  ·  view source on GitHub ↗
(left, right *TreeNode)

Source from the content-addressed store, hash-verified

20}
21
22func isSym(left, right *TreeNode) bool {
23 if left == nil && right == nil {
24 return true
25 }
26
27 // if left XOR right is nil (check above makes XOR)
28 if left == nil || right == nil {
29 return false
30 }
31
32 return (left.Val == right.Val) &&
33 isSym(right.Left, left.Right) &&
34 isSym(left.Left, right.Right)
35}
36
37// Based on in-order traversal being a palindrome.
38// Wrong approach but good lesson on array appending in recursive function.

Callers 1

isSymmetricFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected