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)