Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit274126d

Browse files
refactor 951
1 parentaba3f27 commit274126d

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
importcom.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
publicclass_951 {
206
publicstaticclassSolution1 {
217
publicbooleanflipEquiv(TreeNoderoot1,TreeNoderoot2) {
@@ -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)

[8]ページ先頭

©2009-2025 Movatter.jp