tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
|
|
@ -0,0 +1,20 @@
|
|||
package main
|
||||
import "fmt"
|
||||
|
||||
func uniq(list []int) []int {
|
||||
unique_set := make(map[int] bool, len(list))
|
||||
for _, x := range list {
|
||||
unique_set[x] = true
|
||||
}
|
||||
result := make([]int, len(unique_set))
|
||||
i := 0
|
||||
for x := range unique_set {
|
||||
result[i] = x
|
||||
i++
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func main() {
|
||||
fmt.Println(uniq([]int {1,2,3,2,3,4})) // prints: [3 1 4 2]
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue