LeetCode 101-invalid Ric Tree, leetcodesametree
Link: https://leetcode.com/problems/symmetric-tree/
This is to determine whether a binary tree is a symmetric binary tree. At the beginning, I thought that the output would be a forward traversal and then I checked whether it was a return string. But this idea is wrong, for example, [1, 2, 3 ,#, 3, #, 2].
The Code is as follows:
Determine the left subtree of the Left Child and the right subtree of the right child, and the right subtree of the left child and the Right child
Class Solution {public: bool isJudging (TreeNode * nodeLeft, TreeNode * nodeRight) {if (nodeLeft! = NULL & nodeRight! = NULL & nodeLeft-> val = nodeRight-> val) {return isJudging (nodeLeft-> left, nodeRight-> right) & isJudging (nodeLeft-> right, nodeRight-> left);} else if (nodeLeft = NULL & nodeRight = NULL) return true; else return false;} bool isequalric (TreeNode * root) {if (root = NULL) return true; return isJudging (root-> left, root-> right );}};