Skip to content

Instantly share code, notes, and snippets.

@kougazhang
Created September 3, 2021 08:08
Show Gist options
  • Save kougazhang/3398316d1eeceba6d975c17e423cb479 to your computer and use it in GitHub Desktop.
Save kougazhang/3398316d1eeceba6d975c17e423cb479 to your computer and use it in GitHub Desktop.
#golang
func Difference(a, b []string) []string {
res := make([]string, 0)
for _, aItem := range a {
var same bool
for _, bItem := range b {
if aItem == bItem {
same = true
break
}
}
if !same {
res = append(res, aItem)
}
}
return res
}
@kougazhang
Copy link
Author

求 2 个lst 之间的差集,以 a 为基准。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment