Skip to content

Commit dc7067c

Browse files
committed
refactor(Two Sum): 変数名の改善
1 parent e95c3ba commit dc7067c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

go/two_sum.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
package main
33

44
func twoSum(nums []int, target int) []int {
5-
numsMap := make(map[int]int)
5+
numToIndex := make(map[int]int)
66
for i, n := range nums {
7-
if j, ok := numsMap[target-n]; ok {
7+
if j, ok := numToIndex[target-n]; ok {
88
return []int{i, j}
99
}
10-
numsMap[n] = i
10+
numToIndex[n] = i
1111
}
12-
return nil
12+
return nil // 本来ならerrorを返したい
1313
}

0 commit comments

Comments
 (0)