Merge pull request #23 from TCP404/master

添加0001.两数之和 Go版本
This commit is contained in:
Carl Sun 2021-05-12 14:06:24 +08:00 committed by GitHub
commit 6014752a8e
1 changed files with 14 additions and 1 deletions

View File

@ -109,6 +109,19 @@ Python
Go Go
```go
func twoSum(nums []int, target int) []int {
for k1, _ := range nums {
for k2 := k1 + 1; k2 < len(nums); k2++ {
if target == nums[k1] + nums[k2] {
return []int{k1, k2}
}
}
}
return []int{}
}
```