diff --git a/problems/0001.两数之和.md b/problems/0001.两数之和.md index 7425ff4f..6c9d99dd 100644 --- a/problems/0001.两数之和.md +++ b/problems/0001.两数之和.md @@ -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{} +} +``` + @@ -116,4 +129,4 @@ Go: * 作者微信:[程序员Carl](https://mp.weixin.qq.com/s/b66DFkOp8OOxdZC_xLZxfw) * B站视频:[代码随想录](https://space.bilibili.com/525438321) * 知识星球:[代码随想录](https://mp.weixin.qq.com/s/QVF6upVMSbgvZy8lHZS3CQ) -