Skip to content

Commit f636cb1

Browse files
committed
[week3] solve 100. Same Tree
1 parent da53272 commit f636cb1

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

same-tree/bky373.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* TC: O(N)
3+
* SC: O(N)
4+
*/
5+
class Solution {
6+
public boolean isSameTree(TreeNode p, TreeNode q) {
7+
if (p == null && q == null) return true;
8+
if (p == null || q == null || p.val != q.val) return false;
9+
return isSameTree(p.left, q.left) && isSameTree(p.right, q.right);
10+
}
11+
}

0 commit comments

Comments
 (0)