标签:article als href 面试 highlight bsp jee turn post
/* struct TreeNode { int val; struct TreeNode *left; struct TreeNode *right; TreeNode(int x) : val(x), left(NULL), right(NULL) { } }; */ class Solution { public: bool isSymmetrical(TreeNode* pRoot) { if(pRoot==NULL) return true; TreeNode * pRight=pRoot->right; TreeNode * pLeft=pRoot->left; if(pRight==NULL && pLeft==NULL) return true; if(pRight==NULL || pLeft==NULL) return false; return f(pRight,pLeft); } bool f(TreeNode * pLroot,TreeNode * pRroot) { if(pLroot==NULL && pRroot==NULL) return true; if(pLroot==NULL || pRroot==NULL) return false; if(pLroot->val!=pRroot->val) return false; TreeNode * pL1=pLroot->left; TreeNode * pL2=pLroot->right; TreeNode * pR1=pRroot->left; TreeNode * pR2=pRroot->right; return f(pL1,pR2)&&f(pL2,pR1); } };
标签:article als href 面试 highlight bsp jee turn post
原文地址:http://www.cnblogs.com/dd2hm/p/7459211.html