Skip to content

Commit

Permalink
100.Same-Tree.swift
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitriy Buzulutskiy committed Jul 25, 2022
1 parent 897c000 commit 955ab37
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions swift/100-Same-Tree.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class Solution {
func isSameTree(_ p: TreeNode?, _ q: TreeNode?) -> Bool {
if p == nil && q == nil { return true }
if p?.val != q?.val { return false }
return isSameTree(p?.left, q?.left) && isSameTree(p?.right, q?.right)
}
}

0 comments on commit 955ab37

Please sign in to comment.