167. Two Sum II – Input Array Is Sorted
func twoSum(numbers []int, target int) []int {
tmpMap := make(map[int]int, 10)
for idx, val := range numbers {
v, ok := tmpMap[target-val]
if ok {
return []int{v + 1, idx + 1}
}
tmpMap[val] = idx
}
return []int{-1, -1}
}
原创文章,作者:dweifng,如若转载,请注明出处:https://blog.ytso.com/278121.html