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

Commitabff2d1

Browse files
authored
Merge pull requestneetcode-gh#2533 from Anukriti167/patch-10
Create 0951-flip-equivalent-binary-trees.java
2 parentscdfcdd9 +6df3c37 commitabff2d1

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
classSolution {
2+
publicbooleanflipEquiv(TreeNoderoot1,TreeNoderoot2) {
3+
if(root1 ==null &&root2 ==null)returntrue;
4+
if(root1 ==null ||root2 ==null)returnfalse;
5+
if(root1.val !=root2.val)returnfalse;
6+
7+
if(flipEquiv(root1.left,root2.left) &&flipEquiv(root1.right,root2.right)){//if they are euqal
8+
returntrue;
9+
}
10+
if(flipEquiv(root1.right,root2.left) &&flipEquiv(root1.left,root2.right)){// if flipped once
11+
returntrue;
12+
}else{
13+
returnfalse;
14+
}
15+
}
16+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp