From 5ed25890f133524d2ec093593322d2c4814ec356 Mon Sep 17 00:00:00 2001 From: s0___0k <61587396+s0ooo0k@users.noreply.github.com> Date: Thu, 24 Jul 2025 00:12:30 +0900 Subject: [PATCH 1/4] Add two sum solution - s0ooo0k --- two-sum/s0ooo0k.java | 48 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 two-sum/s0ooo0k.java diff --git a/two-sum/s0ooo0k.java b/two-sum/s0ooo0k.java new file mode 100644 index 000000000..444765ce1 --- /dev/null +++ b/two-sum/s0ooo0k.java @@ -0,0 +1,48 @@ +import java.util.Map; + +class Solution { + + /* + * 시간복잡ㄷ도 개선 + * + * 시간복잡도 O(n) + * 공간복잡도 O(n) + */ + public int[] twoSum(int[] nums, int target) { + Map arr = new HashMap<>(); + + for(int i=0; i Date: Thu, 24 Jul 2025 00:17:08 +0900 Subject: [PATCH 2/4] Fix two sum solution - s0ooo0k --- two-sum/s0ooo0k.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/two-sum/s0ooo0k.java b/two-sum/s0ooo0k.java index 444765ce1..6e393fc53 100644 --- a/two-sum/s0ooo0k.java +++ b/two-sum/s0ooo0k.java @@ -44,5 +44,5 @@ public int[] twoSum(int[] nums, int target) { return answer; } */ - -} \ No newline at end of file +} + From ff72247168063b59442d7c7b6e42af8cdb92e0bd Mon Sep 17 00:00:00 2001 From: s0___0k <61587396+s0ooo0k@users.noreply.github.com> Date: Fri, 25 Jul 2025 14:30:07 +0900 Subject: [PATCH 3/4] Add contains-duplicate solution - s0ooo0k --- contains-duplicate/s0ooo0k.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 contains-duplicate/s0ooo0k.java diff --git a/contains-duplicate/s0ooo0k.java b/contains-duplicate/s0ooo0k.java new file mode 100644 index 000000000..a81d2c619 --- /dev/null +++ b/contains-duplicate/s0ooo0k.java @@ -0,0 +1,17 @@ +/* + * 시간복잡도 O(n) + * 공간복잡도 O(n) + */ +class Solution { + public boolean containsDuplicate(int[] nums) { + Set set = new HashSet<>(); + + for(int n : nums) { + if(set.contains(n)){ + return true; + } + set.add(n); + } + return false; + } +} \ No newline at end of file From 9e7950fd37e8a4b159de675511e159041cbd42fb Mon Sep 17 00:00:00 2001 From: s0___0k <61587396+s0ooo0k@users.noreply.github.com> Date: Fri, 25 Jul 2025 14:30:22 +0900 Subject: [PATCH 4/4] Add contains-duplicate solution - s0ooo0k --- contains-duplicate/s0ooo0k.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/contains-duplicate/s0ooo0k.java b/contains-duplicate/s0ooo0k.java index a81d2c619..5b0dd8c37 100644 --- a/contains-duplicate/s0ooo0k.java +++ b/contains-duplicate/s0ooo0k.java @@ -14,4 +14,6 @@ public boolean containsDuplicate(int[] nums) { } return false; } -} \ No newline at end of file +} + +