Search
🥉

Two Sum

Created
2021/12/31 02:02
문제 번호
1
카테고리
Array
Hash Table

Code

제출 날짜
시간
메모리
2021/12/31
4 ms
4.3MB
// 1. Two Sum // // https://leetcode.com/problems/two-sum/ // twoSum function finds indice of the two elements to make target. // Target number can be found only once. // Mapping to make target is necessary. func twoSum(nums []int, target int) []int { cache := map[int]int{} for i, v := range nums { if j, ok := cache[target-v]; ok { return []int{j, i} } cache[v] = i } return []int{} }
Go
복사