Skip to content

Instantly share code, notes, and snippets.

@acoshift
Created October 15, 2017 06:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save acoshift/15f1c0abff4cff7d092ce7523d68df75 to your computer and use it in GitHub Desktop.
Save acoshift/15f1c0abff4cff7d092ce7523d68df75 to your computer and use it in GitHub Desktop.
remove duplicate: hash map
func removeDuplicateMap(arr []int) []int {
p := make(map[int]struct{})
for _, v := range arr {
p[v] = struct{}{}
}
r := make([]int, 0, len(p))
for v := range p {
r = append(r, v)
}
return r
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment