mirror of
https://github.com/cgzirim/seek-tune.git
synced 2025-12-17 17:04:22 +00:00
18 lines
406 B
Go
18 lines
406 B
Go
package shazam
|
|
|
|
// deduplicate returns a list of unique integers from the given array.
|
|
// The order of the given array is not preserved in the result.
|
|
func deduplicate(array []int) []int {
|
|
uniqueMap := make(map[int]struct{})
|
|
|
|
for _, num := range array {
|
|
uniqueMap[num] = struct{}{}
|
|
}
|
|
|
|
var uniqueList []int
|
|
for num := range uniqueMap {
|
|
uniqueList = append(uniqueList, num)
|
|
}
|
|
|
|
return uniqueList
|
|
}
|