Skip to content

Commit 34826b1

Browse files
authored
Merge pull request #1697 from JEONGBEOMKO/main
[JEONGBEOMKO] WEEK 01 solutions
2 parents ec10e96 + 68e6c13 commit 34826b1

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

contains-duplicate/jeongbeomko.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import java.util.HashSet;
22

3+
/*
4+
* 시간복잡도: O(n)
5+
* 공간복잡도: O(n)
6+
* */
37
class Solution {
48
public boolean containsDuplicate(int[] nums) {
59
HashSet<Integer> numSet = new HashSet<>();

two-sum/JEONGBEOMKO.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import java.util.HashMap;
22
import java.util.Map;
3+
/*
4+
시간복잡도: O(n)
5+
공간복잡도: O(n)
6+
*/
37

48
class Solution {
59
public int[] twoSum(int[] nums, int target) {
@@ -10,7 +14,7 @@ public int[] twoSum(int[] nums, int target) {
1014

1115
for(int i=0; i<nums.length; i++) {
1216
int operand = target - nums[i];
13-
if (numberMap.containsKey(operand) && numberMap.get(operand) != i) { // 자기 자신은 제외
17+
if (numberMap.containsKey(operand) && numberMap.get(operand) != i) {
1418
return new int[] { numberMap.get(target - nums[i]), i };
1519
}
1620
}

0 commit comments

Comments
 (0)