Find why collect returns twice as many elements as its input.
Go
func collect(ids []int) []int {
result := make([]int, len(ids))
for _, id := range ids {
result = append(result, id)
}
return result
}
func collect(ids []int) []int {
result := make([]int, len(ids))
for _, id := range ids {
result = append(result, id)
}
return result
}