C++ || DFS || Easy
\n/**\n * Definition for a binary tree node.\n * struct TreeNode {\n *     int val;\n *     TreeNode *left;\n *     TreeNode *right;\n *     TreeNode() : val(0)
```\n/**\n * Definition for a binary tree node.\n * struct TreeNode {\n *     int val;\n *     TreeNode *left;\n *     TreeNode *right;\n *     TreeNode() : val(0), left(nullptr), right(nullptr) {}\n *     TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n *     TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}\n * };\n */\nclass Solution {\npublic:\n    bool solve(TreeNode* root1, TreeNode* root2)\n    {\n        if(root1==NULL && root2==NULL)\n        {\n            return true;\n        }\n        if(root1==NULL || root2==NULL || root1->val!=root2->val)\n        {\n            return false;\n        }\n        if(solve(root1->left,root2->left) && solve(root1->right,root2->right))\n        {\n            return true;\n        }\n        else if(solve(root1->left,root2->right) && solve(root1->right,root2->left))\n        {\n            return true;\n        }\n        return false;\n    }\n    bool flipEquiv(TreeNode* root1, TreeNode* root2) {\n        return solve(root1,root2);\n    }\n};\n```
['Depth-First Search', 'C']