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

Function isSymmetricWrong

symmetric_tree_101/solution.go:39–55  ·  view source on GitHub ↗

Based on in-order traversal being a palindrome. Wrong approach but good lesson on array appending in recursive function.

(root *TreeNode)

Source from the content-addressed store, hash-verified

37// Based on in-order traversal being a palindrome.
38// Wrong approach but good lesson on array appending in recursive function.
39func isSymmetricWrong(root *TreeNode) bool {
40 inOrder := make([]int, 0)
41 inOrder = inorderTraverse(root, inOrder)
42
43 i := 0
44 j := len(inOrder) - 1
45 for i < j {
46 if inOrder[i] != inOrder[j] {
47 return false
48 }
49
50 i++
51 j--
52 }
53
54 return true
55}
56
57func inorderTraverse(root *TreeNode, a []int) []int {
58 if root == nil {

Callers

nothing calls this directly

Calls 1

inorderTraverseFunction · 0.85

Tested by

no test coverage detected