package main
import "fmt"
func UniqueInts(a []int) (b []int) {
m := map[int]bool{}
for _, v := range a {
if _, ok := m[v]; !ok {
b = append(b, v)
m[v] = true
}
}
return b
}
func main() {
s := []int{9, 1, 9, 5, 4, 4, 2, 1, 5, 4, 8, 8, 4, 3, 6, 9, 5, 7, 5}
s1 := UniqueInts(s)
fmt.Printf("Unique Ints: %vn", s1)
}
2018
07-16
07-16
《本文》有 4344 条评论