19 lines
255 B
Go
19 lines
255 B
Go
package main
|
|
|
|
func problem1(val int, nums []int) bool {
|
|
if len(nums) == 0 {
|
|
return false
|
|
}
|
|
|
|
comp := make(map[int]struct{})
|
|
|
|
for _, num := range nums {
|
|
if _, ok := comp[val-num]; ok {
|
|
return true
|
|
}
|
|
comp[num] = struct{}{}
|
|
}
|
|
|
|
return false
|
|
}
|