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 19b847b5ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 1 deletions

View File

@ -109,6 +109,19 @@ Python
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{}
}
```