File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed
src/main/java/com/fishercoder/solutions Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change 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
1212public 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}
You can’t perform that action at this time.
0 commit comments