Skip to content

Commit eac33b0

Browse files
refactor 100
1 parent 376217a commit eac33b0

File tree

1 file changed

+8
-7
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+8
-7
lines changed

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,18 @@
55
/**
66
* 100. Same Tree
77
*
8-
* Given two binary trees, write a function to check if they are equal or not.
9-
* Two binary trees are considered equal if they are structurally identical and the nodes have the same value.
8+
* Given two binary trees, write a function to check if they are equal or not. Two binary trees are
9+
* considered equal if they are structurally identical and the nodes have the same value.
1010
*/
1111

1212
public class _100 {
1313

14+
public static class Solution1 {
1415
public boolean isSameTree(TreeNode p, TreeNode q) {
15-
if (p == null || q == null) {
16-
return p == q;
17-
}
18-
return p.val == q.val && isSameTree(p.left, q.left) && isSameTree(p.right, q.right);
16+
if (p == null || q == null) {
17+
return p == q;
18+
}
19+
return p.val == q.val && isSameTree(p.left, q.left) && isSameTree(p.right, q.right);
1920
}
20-
21+
}
2122
}

0 commit comments

Comments
 (0)