We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1460518 commit 3c20ac8Copy full SHA for 3c20ac8
src/main/java/com/fishercoder/solutions/_100.java
@@ -4,18 +4,17 @@
4
5
/**
6
* 100. Same Tree
7
- * <p>
8
* Given two binary trees, write a function to check if they are equal or not.
9
10
* Two binary trees are considered equal if they are structurally identical and the nodes have the same value.
11
*/
12
13
public class _100 {
14
- //recursion idea flows out naturally.
+
15
public boolean isSameTree(TreeNode p, TreeNode q) {
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);
20
21
0 commit comments