Skip to content

Instantly share code, notes, and snippets.

@samocodes
Created May 11, 2024 02:20
Show Gist options
  • Save samocodes/9d4dfc40204ffcc1eb56705ee1dec398 to your computer and use it in GitHub Desktop.
Save samocodes/9d4dfc40204ffcc1eb56705ee1dec398 to your computer and use it in GitHub Desktop.
func containsDuplicate(nums []int) bool {
m := make(map[int]bool, len(nums))
for _, num := range nums {
if _, ok := m[num]; ok {
return true
} else {
m[num] = true
}
}
return false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment