LeetCode 第一题
来源:互联网 发布:手机音乐后期软件 编辑:程序博客网 时间:2024/05/22 04:46
LeetCode 第一题
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
You may assume that each input would have exactly one solution, and you may not use the same element twice.
Example:
Given nums = [2, 7, 11, 15], target = 9,
Because nums[0] + nums[1] = 2 + 7 = 9,
return [0, 1].
第一题很简单,求两个值加起来等于目标值的坐标。
func twoSum(nums []int, target int) []int { var result []int for index, x := range nums { for j := index + 1; j < len(nums); j++ { if x+nums[j] == target { result = append(result, index) result = append(result, j) break } } if len(result) != 0 { break } } return result}
阅读全文
0 0
- leetcode第一题
- leetcode第一题
- LeetCode OJ 第一题
- Leetcode第一题
- leetcode第一题
- leetcode第一题
- LeetCode第一题
- leetcode第一题
- LeetCode 测试第一题
- LeetCode 第一题
- leetcode第一题twoSum
- LeetCode第一题
- leetcode算法第一题
- LeetCode 1.Two Sum ------------LeetCode 第一题
- leetcode刷题第一题
- leetcode 第一题 two sum
- LeetCode 第一题,Two Sum
- leetcode第一题two sum
- ”JavaScript 秘密花园“ 学习笔记 :
- 使用 qemu 搭建内核开发环境
- 多线程-局部变量和成员变量
- 超键、候选键、主键、外键区别?
- Oracle导出数据字典SQL语句
- LeetCode 第一题
- js模板jsTpl
- mysql集群——(三)多管理节点
- 关于Android打log
- VBA 脚本
- linux安装Apache+php7+mysql
- taglist选项
- Android 验证码倒计时功能的实现
- 06. Yii 2.0 数据库交互