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 ddd020b commit 95e992aCopy full SHA for 95e992a
two-sum/YuuuuuuYu.java
@@ -1,8 +1,8 @@
1
/**
2
- * Runtime: 3ms
+ * Runtime: 2ms
3
* Time Complexity: O(n)
4
*
5
- * Memory: 46.97MB
+ * Memory: 47.41MB
6
* Space Complexity: O(n)
7
8
* Approach: HashMap을 사용하여 짝을 이루는 값(pair) 검사
@@ -14,7 +14,7 @@ public int[] twoSum(int[] nums, int target) {
14
Map <Integer, Integer> map = new HashMap<>();
15
for (int i=0; i<nums.length; i++) {
16
int pair = target-nums[i];
17
- if (map.containsKey(pair) && map.get(pair) != i) {
+ if (map.containsKey(pair)) {
18
return new int[]{i, map.get(pair)};
19
}
20
map.put(nums[i], i);
0 commit comments