Skip to content

Commit 274126d

Browse files
refactor 951
1 parent aba3f27 commit 274126d

File tree

1 file changed

+2
-16
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+2
-16
lines changed

src/main/java/com/fishercoder/solutions/_951.java

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,6 @@
22

33
import com.fishercoder.common.classes.TreeNode;
44

5-
/**
6-
* 951. Flip Equivalent Binary Trees
7-
*
8-
* For a binary tree T, we can define a flip operation as follows: choose any node, and swap the left and right child subtrees.
9-
*
10-
* A binary tree X is flip equivalent to a binary tree Y if and only if we can make X equal to Y after some number of flip operations.
11-
*
12-
* Write a function that determines whether two binary trees are flip equivalent. The trees are given by root nodes root1 and root2.
13-
*
14-
* Note:
15-
* * Each tree will have at most 100 nodes.
16-
* * Each value in each tree will be a unique integer in the range [0, 99].
17-
*/
18-
195
public class _951 {
206
public static class Solution1 {
217
public boolean flipEquiv(TreeNode root1, TreeNode root2) {
@@ -31,8 +17,8 @@ public boolean flipEquiv(TreeNode root1, TreeNode root2) {
3117
}
3218

3319
return (
34-
(flipEquiv(root1.left, root2.left) && flipEquiv(root1.right, root2.right))
35-
|| (flipEquiv(root1.left, root2.right) && flipEquiv(root1.right, root2.left))
20+
(flipEquiv(root1.left, root2.left) && flipEquiv(root1.right, root2.right))
21+
|| (flipEquiv(root1.left, root2.right) && flipEquiv(root1.right, root2.left))
3622
);
3723
}
3824
}

0 commit comments

Comments
 (0)