File tree Expand file tree Collapse file tree 1 file changed +17
-12
lines changed Expand file tree Collapse file tree 1 file changed +17
-12
lines changed Original file line number Diff line number Diff line change
1
+ package week01 .twosum ;
2
+
1
3
import java .util .HashMap ;
2
4
import java .util .Map ;
3
5
4
- class Solution {
5
- public int [] twoSum (int [] nums , int target ) {
6
- Map <Integer , Integer > numberMap = new HashMap <>();
7
- for (int i =0 ; i <nums .length ; i ++) {
8
- numberMap .put (nums [i ], i );
9
- }
6
+ public class JEONGBEOMKO {
10
7
11
- for (int i =0 ; i <nums .length ; i ++) {
12
- int operand = target - nums [i ];
13
- if (numberMap .containsKey (operand ) && numberMap .get (operand ) != i ) { // ์๊ธฐ ์์ ์ ์ ์ธ
14
- return new int [] { numberMap .get (target - nums [i ]), i };
8
+ class Solution {
9
+ public int [] twoSum (int [] nums , int target ) {
10
+ Map <Integer , Integer > numberMap = new HashMap <>();
11
+ for (int i =0 ; i <nums .length ; i ++) {
12
+ numberMap .put (nums [i ], i );
15
13
}
16
- }
17
14
18
- return new int [] {};
15
+ for (int i =0 ; i <nums .length ; i ++) {
16
+ int operand = target - nums [i ];
17
+ if (numberMap .containsKey (operand ) && numberMap .get (operand ) != i ) { // ์๊ธฐ ์์ ์ ์ ์ธ
18
+ return new int [] { numberMap .get (target - nums [i ]), i };
19
+ }
20
+ }
21
+
22
+ return new int [] {};
23
+ }
19
24
}
20
25
}
You canโt perform that action at this time.
0 commit comments