1. 两数相加

给定一个整数数组 nums 和一个目标值 target,请你在该数组中找出和为目标值的那 两个 整数,并返回他们的数组下标。

你可以假设每种输入只会对应一个答案。但是,你不能重复利用这个数组中同样的元素。

示例:

给定 nums = [2, 7, 11, 15], target = 9

因为 nums[0] + nums[1] = 2 + 7 = 9

所以返回 [0, 1]

func twoSum(nums []int, target int) []int {
res := []int{}
for k1,v1 := range nums {
for k2,v2 := range nums {
if ((v1 + v2) == target) {
res = []int{k1,k2}
break
}
}
}
return res
}

最新文章

  1. ObjectStream 及 序列化 介绍
  2. Apkplug 开发常见问题解答
  3. C语言字符串处理函数
  4. HDU 5053 the Sum of Cube
  5. jQuery-事件以及动画
  6. OpenHCI - 4.2 Endpoint Descriptor
  7. VK Cup 2012 Qualification Round 1 C. Cd and pwd commands 模拟
  8. 自定义构造、description方法、SEL
  9. mysql出现Can't connect to MySQL server on 'localhost' (10061)的解决方法
  10. inux中shell变量$#,$@,$0,$1,$2的含义
  11. nvm配置
  12. JEECG中出现Java.sql.SQLException: Value 'xxxx' can not be represented as java.sql.Timestamp的解决办法
  13. 信息安全之路-web-xss学习(2)
  14. np.corrcoef()方法计算数据皮尔逊积矩相关系数(Pearson's r)
  15. Flume 1.5.0简单部署试用
  16. UVa 12219 公共表达式消除
  17. hadoop2.6 上hive运行 报“native-lzo library not available”异常处理
  18. angularJS1笔记-(20)-模块化加载机制seajs
  19. 一些常见http状态码
  20. ShipStation Now Uses AWS And Amazon Fulfillment To Automatically Ship From eBay, Sears And Other Marketplaces

热门文章

  1. java创建泛型的实例
  2. java jvm虚拟机类加载过程
  3. idea安装破解一条龙
  4. 为Azure DevOps Server (TFS) 配置安全访问(HTTPS with SSL)
  5. Kubernetes容器集群管理环境 - 完整部署(下篇)
  6. Oracle SQL调优之表设计
  7. python asyncio wait和gather
  8. maven项目配置使用jdk1.8进行编译的插件
  9. Spring源码系列 — Bean生命周期
  10. WPF 有任何Focus问题,就找 Keyboard_Navigation