当前位置:网站首页>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]
边栏推荐
- MySQL inserts query results into other tables
- 【MySQL】表数据的增删查改(DML)
- 数组 移动0
- C language -- 10 first knowledge of structure
- SoC development environment and hardware development preparation
- . Net open source free lunch is over?
- Business based precipitation component = & gt; manage-table
- To do desktop plug-in, a good helper for office workers
- 【phpstorm】 No data sources are configured to run this SQL and provide advanced c
- Only three steps are needed to learn how to use low code thingjs to connect with Sen data Dix data
猜你喜欢

Understanding of related concepts of target detection

C language -- 8 familiar keywords

【MySQL】表结构的增删查改操作(DDL)
![[1024 ways to play windows azure] 75 Fast cloud database migration seamlessly migrate alicloud RDS SQL server to azure SQL databas](/img/00/798455f2db289e3aaed36981ea1e7c.png)
[1024 ways to play windows azure] 75 Fast cloud database migration seamlessly migrate alicloud RDS SQL server to azure SQL databas

Forward slash "/", backslash "\," escape character "\" and file path separator cannot be clearly remembered
![[Warning] TIMESTAMP with implicit DEFAULT value is deprecated](/img/e8/53c18a7944d160238f2f1c0f8f04b1.jpg)
[Warning] TIMESTAMP with implicit DEFAULT value is deprecated

构建幼儿Steam教育实施策略

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

Abbexa cell free DNA kit instructions

C language ---9 first knowledge of macros and pointers
随机推荐
[qingniaochangping campus of Peking University] the coordinated development of vocational education and general education, will this year's high school entrance examination be easy?
C language ---9 first knowledge of macros and pointers
Install MySQL on Linux system. Problems encountered in xshell
Shell implements SSH login and executes commands
Standard dual airbags, starting from 48900 for butcher Chang'an Lumin
Abbexa acrylamide peg NHS instructions
The process of keyword search in Oracle tables
【Microsoft Azure 的1024种玩法】七十五.云端数据库迁移之快速将阿里云RDS SQL Server无缝迁移到Azure SQL Databas
Super detailed tutorial for installing mysql8 in centos7 (no pit!)
MySQL insère les résultats de la requête dans une autre table
Rotate navigation bar
C language -- 3 variables for beginners
【C#】overide可重写从更高父级继承来的virtual方法
Exec function of PHP
If else is too easy to use? (understanding this article will further improve your logic)
【MySQL】表数据的增删查改(DML)
Junior high school graduates who choose secondary vocational schools can also be promoted to institutions of higher learning
Cordova plugin /jpush phonegap Aurora push_ Local push_ Message push
How to realize the marketing purpose of small program integral mall
PHP pseudo protocol implementation command execution details