We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3568b91 commit fe794afCopy full SHA for fe794af
two-sum/sora0319.java
@@ -1,4 +1,23 @@
1
import java.util.*;
2
+
3
+// 개선안
4
+class Solution {
5
+ public int[] twoSum(int[] nums, int target) {
6
+ Map<Integer,Integer> checkNums = new HashMap<>();
7
8
+ for(int i = 0; i < nums.length; i++){
9
+ if(checkNums.containsKey(target - nums[i])){
10
+ int place = checkNums.get(target - nums[i]);
11
+ return new int[]{place, i};
12
+ }
13
+ checkNums.put(nums[i], i);
14
15
+ return new int[]{};
16
17
+}
18
19
20
+// 초기 구성안
21
class Solution {
22
public int[] twoSum(int[] nums, int target) {
23
Map<Integer,Integer> element = new HashMap<>();
0 commit comments