Skip to content

Commit cafc298

Browse files
feat: contains-duplicate
1 parent d64c4ae commit cafc298

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Time complexity, O(n)
2+
// Space complexity, O(n)
3+
func containsDuplicate(nums []int) bool {
4+
hashMap := map[int]bool{}
5+
for _, num := range nums {
6+
if hashMap[num] {
7+
return true
8+
} else {
9+
hashMap[num] = true
10+
}
11+
}
12+
return false
13+
}

0 commit comments

Comments
 (0)