当前位置:网站首页>Sum of two array numbers
Sum of two array numbers
2022-06-10 22:11:00 【Morris_】
Array LC Sum of two numbers
Given an array of integers nums And an integer target value target, Please find... In the array And is the target value target the Two Integers , And return their array subscripts .
You can assume that each input corresponds to only one answer . however , The same element in the array cannot be repeated in the answer .
You can return the answers in any order .
- Swift Realization
Input [0, 0, 1, 0]
var nums: [Int] = [0, 0, 1, 0]
print(twoSum(nums, 1))
func twoSum(_ nums: [Int],_ target: Int) -> [Int] {
for i in 0..<nums.count {
for j in (i+1)..<nums.count {
if nums[i] + nums[j] == target {
return [i, j]
}
}
}
return []
}
Output [0, 2]
边栏推荐
- Only this is the most true reason why leaders promote you. The rest is nonsense!
- Abbexa cell free DNA kit instructions
- C language - quick sorting in sorting
- CentOS7安装MySQL8的超级详细教程(无坑!)
- MySQL数据库如何查看表占用空间大小
- Icml2022 | sharp maml: model independent meta learning for sharpness perception
- 【phpstorm】 No data sources are configured to run this SQL and provide advanced c
- CentOS7环境下MySQL8常用命令小结
- String analysis and use
- If else is too easy to use? (understanding this article will further improve your logic)
猜你喜欢

OC swift hybrid

Notes to entry: do I need to know programming for O & M?

Abbexa cell free DNA kit instructions

C language ---5 initial string, escape character and comment

Standard dual airbags, starting from 48900 for butcher Chang'an Lumin

C language -- 7 operators

Interpreting the new ecology of education in maker space

NFT copyright / royalties

Abbexa low sample size chicken lysozyme C (Lyz) ELISA Kit

2022-06-09 RK817 PMU 电池温度检测
随机推荐
Course design of imitation pottery ticket of wechat applet
C程序实例1--个人通讯录管理系统
To do desktop plug-in, a good helper for office workers
ThinkPHP v6.0. X deserialization vulnerability recurrence
OC swift hybrid
数组 求上升区间的高度和
Exec function of PHP
Mysql的回表查询?如何避免?
Shell implements SSH login and executes commands
C语言判断文件或文件夹是否存在
SQL第四练:字符串处理函数
C language ---6 first knowledge of selection statement, loop statement, function and array
Install MySQL on Linux system. Problems encountered in xshell
C language -- 4 first-time constant
Cordova plugin /jpush phonegap Aurora push_ Local push_ Message push
Introduction to ZigBee module wireless transmission star topology networking structure
字符串 反转
旋转菜单3.0
数组 删除数组中的重复项
Acl2022 | bert2bert: an efficient pre training method of parameter reuse, which significantly reduces the training cost of oversized models