Skip to content

Instantly share code, notes, and snippets.

@lkrych
Created March 20, 2018 15:06
Show Gist options
  • Save lkrych/312337abb45438f19f031203d54318a3 to your computer and use it in GitHub Desktop.
Save lkrych/312337abb45438f19f031203d54318a3 to your computer and use it in GitHub Desktop.
Un-optimized remove dups
func removeDupsAlt(arr []int) []int {
h := make(map[int]bool)
//O(n) time complexity
for i := 0; i < len(arr); i++ {
h[arr[i]] = true
}
//O(n) space complexity
keys := make([]int, len(h))
i := 0
//O(n) time complexity
for k := range h {
keys[i] = k
i++
}
//O(nlogn) time complexity
return quickSort(keys)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment