C++ recursion
\nclass Solution {\n    bool cmpFlip(TreeNode* root1, TreeNode* root2) {\n        if(!root1 && !root2)\n            return true;\n        if(!root1 || !root2)\n
```\nclass Solution {\n    bool cmpFlip(TreeNode* root1, TreeNode* root2) {\n        if(!root1 && !root2)\n            return true;\n        if(!root1 || !root2)\n            return false;\n        \n        if(root1->val != root2->val)\n            return false;\n        \n        bool b1 = cmpFlip(root1->left, root2->left);\n        bool b2 = cmpFlip(root1->right, root2->right);\n        \n        if(b1 && b2)\n            return true;\n        \n        if(!b1)\n            b1 = cmpFlip(root1->left, root2->right);\n        if(!b2)\n            b2 = cmpFlip(root1->right, root2->left);\n        return b1 & b2;\n    }\npublic:\n    bool flipEquiv(TreeNode* root1, TreeNode* root2) {\n        return cmpFlip(root1, root2);\n    }\n};\n```
[]