标签:
1 class Solution { 2 public: 3 bool isSame(TreeNode* p1, TreeNode* p2) 4 { 5 if(!p1 && !p2) 6 return true; 7 if(!p1 || !p2) 8 return false; 9 if(p1->val == p2->val) 10 return isSame(p1->left,p2->right) && isSame(p1->right,p2->left); 11 else return false; 12 } 13 bool isSymmetrical(TreeNode* pRoot) 14 { 15 if(pRoot == NULL) 16 return true; 17 return isSame(pRoot,pRoot); 18 } 19 20 };
标签:
原文地址:http://www.cnblogs.com/daocaorenblog/p/5463295.html