Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit187a224

Browse files
Create 0001_Two Sum.java
1 parente50e48e commit187a224

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

‎Solutions/0001_Two Sum.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
classSolution
2+
{
3+
publicint[]twoSum(int[]nums,inttarget)
4+
{
5+
int[]result =newint[2];
6+
booleanflag=false;
7+
for(inti=0;i<nums.length;i++)
8+
{
9+
for(intj=i;j<nums.length;j++)
10+
{
11+
if(i!=j&&nums[i]+nums[j]==target)
12+
{
13+
result[0]=i;
14+
result[1]=j;
15+
flag=true;
16+
break;
17+
}
18+
}
19+
if(flag)
20+
break;
21+
}
22+
returnresult;
23+
}
24+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp