DailyCodingProblems/problem1.go
Dustin Pianalto f1dc228da4 Problem 1
2020-08-29 19:56:22 -08:00

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
}