/*
struct TreeNode {
    int val;
    struct TreeNode *left;
    struct TreeNode *right;
    TreeNode(int x) :
            val(x), left(NULL), right(NULL) {
    }
};
*/
class Solution {
public:
    bool dfs(TreeNode* left, TreeNode* right) {
        if(!left) return !right;
        if(!right) return !left;
        if(left->val != right->val) return false;
        return dfs(left->right, right->left) && dfs(left->left, right->right);
    }
    bool isSymmetrical(TreeNode* pRoot) {
        if(!pRoot)
            return true;
        return dfs(pRoot->left, pRoot->right);
    }

};