File tree 1 file changed +8
-7
lines changed
src/main/java/com/fishercoder/solutions
1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change 5
5
/**
6
6
* 100. Same Tree
7
7
*
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.
10
10
*/
11
11
12
12
public class _100 {
13
13
14
+ public static class Solution1 {
14
15
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 );
19
20
}
20
-
21
+ }
21
22
}
You can’t perform that action at this time.
0 commit comments