当前位置:网站首页>[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;
}
}
边栏推荐
- Free lottery --- PMP renewal PDU | PMP knowledge map
- Building crud applications in golang
- PMP test difficulty and pass rate
- Kaust:deyao Zhu | value memory map: a graph structured world model based on off-line reinforcement learning
- Apispace empty number detection API interface is free and easy to use
- The difference between caching and buffering
- Do you really use the buffer buffer in PostGIS?
- 如何快速查询手机号码归属地和运营商
- C # graphic tutorial (Fourth Edition) chapter7-7.6.1 virtual and override
- The difference between philosophy and Literature
猜你喜欢

安全事故等级划分为哪几级

H5時代leaflet中還在用DivIcon?

Enterprise wechat H5_ Authentication, PC website, enterprise wechat scanning code, authorized login

PMP test difficulty and pass rate
![[matlab] symbol calculation](/img/a5/7682a465ca2813a83114c091580c53.png)
[matlab] symbol calculation

How to visit a website

Based on three JS offshore wind power digital twin 3D effect

OSM map local publishing - how to generate vector maps of provinces and cities

Will the salary increase after obtaining PMP certification?

Machining Industry MES system Mold Industry MES system CNCl Medium Industry MES System MES code scanning and reporting MES data collection
随机推荐
Start blogging
一篇文章学会子网划分
Online examination questions for September examination of financial management
Start of u-boot S analysis (IV)
H5时代leaflet中还在用DivIcon?
PMP registration conditions, time, cost, new version related information
21 Chundong University blasting safety online peacetime operation 123 [standard answer]
Learn to divide subnets in an article
2022施工員-設備方向-通用基礎(施工員)操作證考試題及模擬考試
June 11, 2022 diary: Mr. Wang's spring, mixed in
2022-06-13日报: 图灵奖得主:想要在学术生涯中获得成功,需要注意哪些问题?
C language standard IO, for example: fread(), fwrite(), fgetc(), etc. (end)
Will PM (Project Manager) take the PMP Exam?
How to make maputnik, a vector tile matching artifact, support GeoServer
Explain bio, NiO, AIO in detail
63. 不同路径 II
Basics of network security (1)
【HCIE论述】STP-A
Buuctf-[ciscn 2019 preliminary]love math
Why study PMP?