Skip to content

Commit

Permalink
Merge pull request #171 from Roshanzha/patch-10
Browse files Browse the repository at this point in the history
Create notepad.java
  • Loading branch information
pujazha authored Oct 24, 2024
2 parents 3ce120f + 55546e0 commit 9e052bd
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions notepad.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
class Solution {
public boolean flipEquiv(TreeNode root1, TreeNode root2) {

return checker(root1, root2);
}

private boolean checker(TreeNode node1, TreeNode node2) {
if (node1 == null && node2 == null) {
return true;
}
if (node1 == null || node2 == null || node1.val != node2.val) {
return false;
}

return (checker(node1.left, node2.left) || checker(node1.left, node2.right)) &&
(checker(node1.right, node2.right) || checker(node1.right, node2.left));
}
}

0 comments on commit 9e052bd

Please sign in to comment.