Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions contains-duplicate/jeongbeomko.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import java.util.HashSet;

/*
* 시간복잡도: O(n)
* 공간복잡도: O(n)
* */
class Solution {
public boolean containsDuplicate(int[] nums) {
HashSet<Integer> numSet = new HashSet<>();
Expand Down
6 changes: 5 additions & 1 deletion two-sum/JEONGBEOMKO.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import java.util.HashMap;
import java.util.Map;
/*
시간복잡도: O(n)
공간복잡도: O(n)
*/

class Solution {
public int[] twoSum(int[] nums, int target) {
Expand All @@ -10,7 +14,7 @@ public int[] twoSum(int[] nums, int target) {

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