8000 Create 0001_Two Sum.java · berkayzaimdev/LeetCode-Java@187a224 · GitHub
[go: up one dir, main page]

Skip to content

Commit 187a224

Browse files
Create 0001_Two Sum.java
1 parent e50e48e commit 187a224

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+
class Solution
2+
{
3+
public int[] twoSum(int[] nums, int target)
4+
{
5+
int[] result = new int[2];
6+
boolean flag=false;
7+
for(int i=0;i<nums.length;i++)
8+
{
9+
for(int j=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+
return result;
23+
}
24+
}

0 commit comments

Comments
 (0)
0