HI, can someone please help figuring out what I am doing wrong here
- https://play.golang.org/p/wmvsBoR4SvL
I am doing an append on result.
Confusion is in this part of the answer -I am not able to figure out why does index 4 in Result get overwritten
Result is [[] [0] [3] [0 3] [5]]
I is 1 size is 4 subset is [0]
subset is [0 5] added n 5
Len and cap for result is 5 8
Len and cap for result after append is 6 8
Result is [[] [0] [3] [0 5] [5] [0 5]]
I am doing an append on result.
No any search results
You already invited:
1 Answers
Cyrus
Upvotes from:
I saw `for _, n := range nums{` and then `subset = append(subset, n)`
n is a slice...and when it gets reused and you modify it...