C++ Simple Recursive Solution with detail Explanation: 4ms
In this question, we have to check these following conditions,\ni) If root1 is not null and root2 is null then we have to return 0\nii) If root1 is null and roo
In this question, we have to check these following conditions,\ni) If root1 is not null and root2 is null then we have to return 0\nii) If root1 is null and root2 is not null then we have to return 0\niii) if root1 and root2 both are null then they are equal and return 1\niv) and at last if both are not null and root1-val != root2->val then we have to return 0\n\nWe have to check these condition recursively for the normal (left,right traversal) and some alternate traversal (because some subtree are flip ).\n\nSee this Code\n\n```\nclass Solution {\npublic:\n    bool flipEquiv(TreeNode* root1, TreeNode* root2) {\n       \n        // check condition first,second,third\n        if(root1 == NULL || root2 == NULL){\n            return root1 == root2;\n        }\n        \n        //check condition fourth\n        if(root1->val != root2->val){\n            return 0;\n        }\n    \n        return ( flipEquiv(root1->left,root2->right) && flipEquiv(root1->right,root2->left) )|| (flipEquiv(root1->left,root2->left) && flipEquiv(root1->right,root2->right));\n    }\n};\n\n```
['Recursion', 'C']