Skip to content

Instantly share code, notes, and snippets.

@acoshift
Created October 15, 2017 06:24
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/d1768da071e429e0f86c49624d519307 to your computer and use it in GitHub Desktop.
Save acoshift/d1768da071e429e0f86c49624d519307 to your computer and use it in GitHub Desktop.
remove duplicate: loop
func removeDuplicateLoop(arr []int) []int {
p := append([]int{}, arr...)
for i := range p {
for j := i + 1; j < len(p); j++ {
if p[i] == p[j] {
p = append(p[:j], p[j+1:]...)
j--
}
}
}
return p
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment