Your stickers are in mine (with repeats), and the ones your friend wants are in wants (no repeats). You can only give a sticker away if you have 2 or more of it. Write Swaps(mine, wants) to return the stickers you can give, in the order of wants; none gives an empty slice.
Swaps([]string{"cat", "dog", "cat", "owl", "owl"}, []string{"owl", "dog", "cat"})→['owl', 'cat']Swaps([]string{"cat"}, []string{"cat"})→[]func Swaps(mine, wants []string) []stringpackage main
func Swaps(mine, wants []string) []string {
count := map[string]int{}
for _, s := range mine {
// your code here: add 1 to this sticker's count
}
give := []string{}
for _, w := range wants {
// your code here: if you have 2 or more of w, add it to give
}
return give
}
Run tries the examples. When they look right, Submit.