Skip to content

Commit ec1eac4

Browse files
Merge pull request youngyangyang04#555 from YellowPeaches/master
update 0100相同的树java版
2 parents 06ed002 + 7ff7afc commit ec1eac4

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

problems/0100.相同的树.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,22 @@ public:
172172

173173
Java:
174174

175+
```java
176+
class Solution {
177+
public boolean isSameTree(TreeNode p, TreeNode q) {
178+
if (p == null && q == null) {
179+
return true;
180+
} else if (q == null || p == null) {
181+
return false;
182+
} else if (q.val != p.val) {
183+
return false;
184+
} else {
185+
return isSameTree(q.left, p.left) && isSameTree(q.right, p.right);
186+
}
187+
}
188+
}
189+
190+
```
175191
Python:
176192

177193
Go:

0 commit comments

Comments
 (0)