Skip to content

Commit

Permalink
add sol
Browse files Browse the repository at this point in the history
  • Loading branch information
ductnn committed Feb 26, 2024
1 parent c35af1e commit 01e1aef
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions leetcode/100.SameTree/sameTree.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// https://leetcode.com/problems/same-tree

package main

/**
* Definition for a binary tree node.
* type TreeNode struct {
* Val int
* Left *TreeNode
* Right *TreeNode
* }
*/

type TreeNode struct {
Val int
Left *TreeNode
Right *TreeNode
}

func isSameTree(p *TreeNode, q *TreeNode) bool {
if p == q {
return true
}

if p == nil || q == nil || p.Val != q.Val {
return false
}

return isSameTree(p.Left, q.Left) && isSameTree(p.Right, q.Right)
}

0 comments on commit 01e1aef

Please sign in to comment.