Javascript Recursive 98%
The trick is to realize that a branch is a flip if all the children are the same. There are only two scenarios where the children match.\n\nScenario A. The bran
The trick is to realize that a branch is a flip if all the children are the same. There are only two scenarios where the children match.\n\nScenario A. The branches match each other\n```\n    Tree A        Tree B\n       1             1\n\t  /             /\n    2              2\n```\n\nScenario B. The branches are flipped\n```\n    Tree A        Tree B\n       1             1\n\t  /                \\\n     2                  2\n```\n\nHere\'s the code.\n```\nconst flipEquiv = (root1, root2) => {\n  // Base case recursion\n  if (root1 === null && root2 === null) return true;\n  \n  if (root1 && root2 && root1.val === root2.val) {\n    // return true if scenario A or scenario B is true\n    return (flipEquiv(root1.left, root2.left) && flipEquiv(root1.right, root2.right))\n      || (flipEquiv(root1.left, root2.right) && flipEquiv(root1.right, root2.left))\n  } else {\n    return false;\n  }\n};\n```
[]