parent
c7c211c30b
commit
87a51bcb69
|
|
@ -237,6 +237,26 @@ class Solution:
|
|||
return True
|
||||
```
|
||||
Go:
|
||||
> 递归法
|
||||
```go
|
||||
func isSameTree(p *TreeNode, q *TreeNode) bool {
|
||||
if p != nil && q == nil {
|
||||
return false
|
||||
}
|
||||
if p == nil && q != nil {
|
||||
return false
|
||||
}
|
||||
if p == nil && q == nil {
|
||||
return true
|
||||
}
|
||||
if p.Val != q.Val {
|
||||
return false
|
||||
}
|
||||
Left := isSameTree(p.Left, q.Left)
|
||||
Right := isSameTree(p.Right, q.Right)
|
||||
return Left && Right
|
||||
}
|
||||
```
|
||||
|
||||
JavaScript:
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue