两数之和
https://leetcode.cn/problems/two-sum/
func twoSum(nums []int, target int) []int { mp:=make(map[int]int,len(nums)) //某个数字出现的次数 for i := range nums { if p, ok := mp[target-nums[i]]; ok { return []int{p, i} } mp[nums[i]] = i } return nil }
等风起的那一天,我已准备好一切