Skip to content

Commit

Permalink
Create notepad.java
Browse files Browse the repository at this point in the history
  • Loading branch information
Roshanzha authored Oct 24, 2024
1 parent 3ce120f commit 55546e0
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 55546e0

Please sign in to comment.