leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

0951.cpp (441B)


0 class Solution { 1 public: 2 bool flipEquiv(const TreeNode *root1, const TreeNode *root2) const { 3 if (!root1 && !root2) return true; 4 if (!root1 || !root2) return false; 5 if (root1->val != root2->val) return false; 6 7 return (flipEquiv(root1->left, root2->left) && flipEquiv(root1->right, root2->right)) || 8 (flipEquiv(root1->right, root2->left) && flipEquiv(root1->left, root2->right)); 9 } 10 };