** * 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)
| 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. |
| 18 | func isSymmetric(root *TreeNode) bool { |
| 19 | return isSym(root, root) |
| 20 | } |
| 21 | |
| 22 | func isSym(left, right *TreeNode) bool { |
| 23 | if left == nil && right == nil { |