Skip to content

Commit d8dff05

Browse files
committed
feat : solve contains-duplicate
1 parent 53ce7c7 commit d8dff05

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

contains-duplicate/sam.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)