I am trying to solve equivalent binary trees exercise on go tour. Here is what I did;
package main
import \"tour/tree\"
import \"fmt\"
// Walk walks the tr
Tried to solve this problem using map structure.
func Same(t1, t2 *tree.Tree) bool {
countMap := make(map[int]int)
ch := make(chan int)
go Walk(t1, ch)
for v := range ch {
countMap[v]++
}
ch = make(chan int)
go Walk(t2, ch)
for v := range ch {
countMap[v]--
if countMap[v] < 0 {
return false
}
}
return true
}