Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 3c20ac8

Browse files
refactor 100
1 parent 1460518 commit 3c20ac8

File tree

1 file changed

+2
-3
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+2
-3
lines changed

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

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,17 @@
44

55
/**
66
* 100. Same Tree
7-
* <p>
87
* Given two binary trees, write a function to check if they are equal or not.
9-
* <p>
108
* Two binary trees are considered equal if they are structurally identical and the nodes have the same value.
119
*/
1210

1311
public class _100 {
14-
//recursion idea flows out naturally.
12+
1513
public boolean isSameTree(TreeNode p, TreeNode q) {
1614
if (p == null || q == null) {
1715
return p == q;
1816
}
1917
return p.val == q.val && isSameTree(p.left, q.left) && isSameTree(p.right, q.right);
2018
}
19+
2120
}

0 commit comments

Comments
 (0)