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

Lines changed: 2 additions & 3 deletions
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy