Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- *knakul853
- **/
- class Solution {
- public:
- bool isSymmetric(TreeNode* root) {
- if( !root ) return true;
- return solve(root->left, root->right);
- }
- bool solve(TreeNode* t1, TreeNode* t2)
- {
- if( t1 == t2 ) return true;
- if( !t1 || !t2) return false;
- if(t1->val != t2->val) return false;
- return solve(t1->left, t2->right) && solve(t1->right, t2->left);
- }
- };
Add Comment
Please, Sign In to add comment