We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 1587b94 + 393b82b commit 4674f26Copy full SHA for 4674f26
go/blind_75/arrays_&_hashing/1-Two-Sum.go
@@ -0,0 +1,14 @@
1
+package arrayandhashing
2
+
3
+func twoSum(nums []int, target int) []int {
4
+ m := make(map[int]int)
5
+ for idx, num := range nums {
6
7
+ if val, found := m[target-num]; found {
8
+ return []int{val, idx}
9
+ }
10
11
+ m[num] = idx
12
13
+ return nil
14
+}
go/blind_75/arrays_&_hashing/217-Contains-Duplicate.go
@@ -0,0 +1,13 @@
+package arrayAndHashing
+func containsDuplicate(nums []int) bool {
+ freqMap := make(map[int]int)
+ for i := 0; i < len(nums); i++ {
+ if _, ok := freqMap[nums[i]]; ok {
+ return true
+ freqMap[nums[i]] += 1
+ return false
0 commit comments