From c40d010c09f4c5b7e36587c459e53b79c0a7cf2f Mon Sep 17 00:00:00 2001 From: ductnn Date: Mon, 18 Dec 2023 10:55:18 +0700 Subject: [PATCH] update --- .../leaf-SimilarTrees.go | 36 +++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/leetcode/leetcode75/BinaryTree-DFS/872.Leaf-SimilarTrees/leaf-SimilarTrees.go b/leetcode/leetcode75/BinaryTree-DFS/872.Leaf-SimilarTrees/leaf-SimilarTrees.go index cad152d..aa9c9ad 100644 --- a/leetcode/leetcode75/BinaryTree-DFS/872.Leaf-SimilarTrees/leaf-SimilarTrees.go +++ b/leetcode/leetcode75/BinaryTree-DFS/872.Leaf-SimilarTrees/leaf-SimilarTrees.go @@ -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)