✅ C++ || Beats 100% || 6 lines
c++\nclass Solution {\n    bool traverse(TreeNode* root1, TreeNode* root2) {\n        if (!root1 && !root2) return true;\n        if (root1 == NULL || root2 == 
```c++\nclass Solution {\n    bool traverse(TreeNode* root1, TreeNode* root2) {\n        if (!root1 && !root2) return true;\n        if (root1 == NULL || root2 == NULL || root1->val != root2->val) return false;\n        \n        auto root1Val = root1 ? root1->left ? root1->left->val: -1 : -1;\n        auto root2Val = root2 ? root2->left ? root2->left->val: -1 : -1;\n        if (root1Val != root2Val) swap(root1->left, root1->right);\n        \n        return traverse(root1->left, root2->left) && traverse(root1->right, root2->right);\n    }\npublic:\n    bool flipEquiv(TreeNode* root1, TreeNode* root2) {\n        return traverse(root1, root2);\n    }\n};\n```\n\n**For more solutions, check out this \uD83C\uDFC6  [GITHUB REPOSITORY](https://github.com/MuhtasimTanmoy/playground) with over 1500+ solutions.**
[]