Skip to content

Commit 3883fe4

Browse files
authored
Merge pull request #1711 from SamTheKorean/main
[SAM] WEEK 01 Solutions
2 parents 19588b2 + 8c0007e commit 3883fe4

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

contains-duplicate/SamTheKorean.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// TC : O(n) : it iterates for the length of nums
2+
// SC : O(n) : hashmap is created with the size of nums
3+
4+
func containsDuplicate(nums []int) bool {
5+
hashmap := make(map[int]bool)
6+
7+
for i:=0;i<len(nums);i++ {
8+
if hashmap[nums[i]] {
9+
return true
10+
}
11+
12+
hashmap[nums[i]] = true
13+
}
14+
15+
return false
16+
}
17+

0 commit comments

Comments
 (0)