MCPcopy Create free account
hub / github.com/austingebauer/go-leetcode / containsDuplicate

Function containsDuplicate

contains_duplicate_217/solution.go:3–14  ·  view source on GitHub ↗
(nums []int)

Source from the content-addressed store, hash-verified

1package contains_duplicate_217
2
3func containsDuplicate(nums []int) bool {
4 m := make(map[int]bool)
5 for _, n := range nums {
6 if m[n] {
7 return true
8 }
9
10 m[n] = true
11 }
12
13 return false
14}
15
16/*
17Note: bit shifting technique only worked for n > -1 in nums

Callers 1

Test_containsDuplicateFunction · 0.85

Calls

no outgoing calls

Tested by 1

Test_containsDuplicateFunction · 0.68