C++ Recursion Solution
Runtime: 8 ms, faster than 35.73% of C++ online submissions for Flip Equivalent Binary Trees.\nMemory Usage: 12.3 MB, less than 58.84% of C++ online submissions
Runtime: 8 ms, faster than 35.73% of C++ online submissions for Flip Equivalent Binary Trees.\nMemory Usage: 12.3 MB, less than 58.84% of C++ online submissions for Flip Equivalent Binary Trees.\n\n```\nclass Solution {\npublic:\n    bool flipEquiv(TreeNode* root1, TreeNode* root2) {\n        \n        // 3 base cases for recursion\n        \n        // If both root are NULL then it is valid and we return true\n        if(!root1 && !root2) return true;\n        \n        // If only one root is NULL then it is not valid and we return false\n        if(!root1 || !root2) return false;        \n        \n        // If both root has value mismatch then it is not valid and we return false\n        if(root1->val!=root2->val) return false;\n        \n        // If root1 and root2 value match then we check in their child nodes\n        // Their child nodes can be flip equivalent only in 2 ways, either No Flip or Flip\n            // Either both root1->left == root2->left and root1->right == root2->right => No Flip\n            // Or both root1->left == root2->right and root1->right == root2->left => Flip \n\n        return (flipEquiv(root1->left,root2->left) && flipEquiv(root1->right,root2->right)) || (flipEquiv(root1->left,root2->right) && flipEquiv(root1->right,root2->left));\n    }\n};\n```
['Recursion', 'C', 'Binary Tree']