当前位置:网站首页>[LeetCode]1. Sum of two numbers thirty-four
[LeetCode]1. Sum of two numbers thirty-four
2022-06-13 00:12:00 【PowerDon】
Given an array of integers nums And a target value target, Please find and as the target value in the array Two Integers , And return their array subscripts .
You can assume that each input corresponds to only one answer . however , The same element in an array cannot be used twice .
Example :
Given nums = [2, 7, 11, 15], target = 9
because nums[0] + nums[1] = 2 + 7 = 9
So back [0, 1]
source : Power button (LeetCode)
link :https://leetcode-cn.com/problems/two-sum
Copyright belongs to the network . For commercial reprint, please contact the official authority , Non-commercial reprint please indicate the source .
public class Solution
{
public int[] TwoSum(int[] nums, int target)
{
for (int i = 0; i < nums.Length; i++)
{
for (int j = 0; j < nums.Length; j++)
{
if (i == j)
{
continue;
}
int temp = target - nums[i];
if (nums[j] == temp)
{
return new int[2] {
i, j };
}
}
}
return null;
}
}
边栏推荐
- Will the salary increase after obtaining PMP certification?
- What occupation is suitable for PMP?
- MySQL index
- On the usage details and special usage of switch case
- Real time preview of PHP in browser by vscade
- VHDL编程实验练习题合集
- 2022年3月11日记:王老师的春天,奇异的模板模式
- Matlab [path planning] - UAV drug distribution route optimization
- [C] Inverts the binary of a decimal number and outputs it
- Tsinghua Bosch joint ml center, thbi lab:cheng Yang Ying | realize safety reinforcement learning through the value at risk of constraints
猜你喜欢
![Matlab [path planning] - UAV drug distribution route optimization](/img/b3/637fe426fcc960daf11bf640019589.png)
Matlab [path planning] - UAV drug distribution route optimization

MySql索引

What occupation is suitable for PMP?

PMP renewal | PDU specific operation diagram

Start of u-boot_ Armboot analysis (I)

PLC也能制作小游戏----Codesys编写猜数字小游戏

On the parameters of main function in C language

【Matlab】三维曲线与三维曲面

What can PMP bring to you

leaflet中如何通过透明度控制layerGroup的显示隐藏
随机推荐
Memory address mapping of u-boot
【Matlab】矩阵操作
VHDL编程实验练习题合集
[matlab] matrix transformation and matrix evaluation
在 Golang 中构建 CRUD 应用程序
【HCIE论述】组播IGMP-A
Tsinghua Bosch joint ml center, thbi lab:cheng Yang Ying | realize safety reinforcement learning through the value at risk of constraints
PLC也能制作小游戏----Codesys编写猜数字小游戏
PMP training organization
Test platform series (97) perfect the case part
Information collection for network security (2)
[hcie discussion] multicast igmp-a
June 11, 2022 diary: Mr. Wang's spring, mixed in
63. 不同路径 II
如何让矢量瓦片配图神器maputnik支持 geoserver
Several interview questions in TCP three grips and four swings
leaflet中如何优雅的解决百度、高德地图的偏移问题
How to make maputnik, a vector tile matching artifact, support GeoServer
Running of NCF dapr application instance
APISpace 空号检测API接口 免费好用