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

Function isSymmetric

symmetric_tree_101/solution.go:18–20  ·  view source on GitHub ↗

** * Definition for a binary tree node. * type TreeNode struct { * Val int * Left *TreeNode * Right *TreeNode * } */ Note: good problem! Review this. Use of two pointers to left and right subtree was a new idea to me. This allows us to check each side of the tree, which is differe

(root *TreeNode)

Source from the content-addressed store, hash-verified

16// This allows us to check each side of the tree, which is different to
17// other recursive (pre, in, post) traversals that I'm familiar with.
18func isSymmetric(root *TreeNode) bool {
19 return isSym(root, root)
20}
21
22func isSym(left, right *TreeNode) bool {
23 if left == nil && right == nil {

Callers 1

Test_isSymmetricFunction · 0.85

Calls 1

isSymFunction · 0.85

Tested by 1

Test_isSymmetricFunction · 0.68