Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
ductnn committed Dec 18, 2023
1 parent 492e4d5 commit c40d010
Showing 1 changed file with 34 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,40 @@ func dfs(root *TreeNode, arr *[]int) {

func main() {
// Define the trees
root1 := &TreeNode{Val: 3, Left: &TreeNode{Val: 5, Left: &TreeNode{Val: 6}, Right: &TreeNode{Val: 2, Left: &TreeNode{Val: 7}, Right: &TreeNode{Val: 4}}}, Right: &TreeNode{Val: 1, Left: &TreeNode{Val: 9}, Right: &TreeNode{Val: 8}}}
root2 := &TreeNode{Val: 3, Left: &TreeNode{Val: 5, Left: &TreeNode{Val: 6}, Right: &TreeNode{Val: 7, Left: &TreeNode{Val: 2}, Right: &TreeNode{Val: 4}}}, Right: &TreeNode{Val: 1, Left: &TreeNode{Val: 4}, Right: &TreeNode{Val: 9}}}
root1 := &TreeNode{
Val: 3,
Left: &TreeNode{
Val: 5,
Left: &TreeNode{Val: 6},
Right: &TreeNode{
Val: 2,
Left: &TreeNode{Val: 7},
Right: &TreeNode{Val: 4},
},
},
Right: &TreeNode{
Val: 1,
Left: &TreeNode{Val: 9},
Right: &TreeNode{Val: 8},
},
}
root2 := &TreeNode{
Val: 3,
Left: &TreeNode{
Val: 5,
Left: &TreeNode{Val: 6},
Right: &TreeNode{
Val: 7,
Left: &TreeNode{Val: 2},
Right: &TreeNode{Val: 4},
},
},
Right: &TreeNode{
Val: 1,
Left: &TreeNode{Val: 4},
Right: &TreeNode{Val: 9},
},
}

// Check leaf similarity
result := leafSimilar(root1, root2)
Expand Down

0 comments on commit c40d010

Please sign in to comment.