Skip to content

Commit 12c1c56

Browse files
committed
two-sum
1 parent 984b209 commit 12c1c56

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

two-sum/hjeomdev.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Solution {
2+
public int[] twoSum(int[] nums, int target) {
3+
int[] answer = new int[2];
4+
for (int i = 0; i < nums.length; i++) {
5+
for (int j = i + 1; j < nums.length; j++) {
6+
if (nums[i] + nums[j] == target) {
7+
answer[0] = i;
8+
answer[1] = j;
9+
break;
10+
}
11+
}
12+
}
13+
return answer;
14+
}
15+
}

0 commit comments

Comments
 (0)