Skip to content

Instantly share code, notes, and snippets.

@schaitanya
Created January 22, 2019 02:38
Show Gist options
  • Save schaitanya/01515bde210787f951933ade6ab12649 to your computer and use it in GitHub Desktop.
Save schaitanya/01515bde210787f951933ade6ab12649 to your computer and use it in GitHub Desktop.
package main
import "fmt"
func main() {
fmt.Println(containsDuplicate([]int{1, 2, 3, 4}))
}
func containsDuplicate(nums []int) bool {
ret := make(map[int]bool, len(nums))
for j := 0; j < len(nums); j++ {
if ret[nums[j]] {
return true
} else {
ret[nums[j]] = true
}
}
return false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment