(TreeNode root1, TreeNode root2)
| 15 | */ |
| 16 | class Solution { |
| 17 | public boolean flipEquiv(TreeNode root1, TreeNode root2) { |
| 18 | //base cases |
| 19 | if(root1 == null && root2==null){ |
| 20 | return true; |
| 21 | } |
| 22 | if(root1 == null || root2==null){ |
| 23 | return false; |
| 24 | } |
| 25 | if(root1.val!=root2.val){ |
| 26 | return false; |
| 27 | } |
| 28 | //orignal |
| 29 | boolean isSame = flipEquiv(root1.left, root2.left) && flipEquiv(root1.right, root2.right); |
| 30 | if(isSame){ |
| 31 | return true; |
| 32 | } |
| 33 | //flip |
| 34 | return flipEquiv(root1.left, root2.right) && flipEquiv(root1.right, root2.left); |
| 35 | } |
| 36 | } |
nothing calls this directly
no outgoing calls
no test coverage detected