From cc9a53da07fff3b6001776337f6d2aab9ca793eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=80=E1=85=B5=E1=86=B7=E1=84=80=E1=85=A1=E1=84=8B?= =?UTF-8?q?=E1=85=B3=E1=86=AB?= Date: Mon, 31 Mar 2025 09:26:34 +0900 Subject: [PATCH 1/4] contains duplicate solution --- contains-duplicate/paran22.py | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 contains-duplicate/paran22.py diff --git a/contains-duplicate/paran22.py b/contains-duplicate/paran22.py new file mode 100644 index 000000000..c33553ccc --- /dev/null +++ b/contains-duplicate/paran22.py @@ -0,0 +1,4 @@ +class Solution: + def containsDuplicate(self, nums: List[int]) -> bool: + unique_nums = set(nums) + return len(unique_nums) != len(nums) From abfd7d9ff8138fdec8bd9d522f587e74becbd9d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=80=E1=85=B5=E1=86=B7=E1=84=80=E1=85=A1=E1=84=8B?= =?UTF-8?q?=E1=85=B3=E1=86=AB?= Date: Tue, 1 Apr 2025 09:54:11 +0900 Subject: [PATCH 2/4] two-sum solution --- two-sum/paran22.py | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 two-sum/paran22.py diff --git a/two-sum/paran22.py b/two-sum/paran22.py new file mode 100644 index 000000000..5aed9b4b6 --- /dev/null +++ b/two-sum/paran22.py @@ -0,0 +1,9 @@ +class Solution: + # 시간복잡도 : O(n) + def twoSum(self, nums: List[int], target: int) -> List[int]: + num_dict = {num: i for i, num in enumerate(nums)} + + for i, first_num in enumerate(nums): + second_num = target - first_num + if second_num in num_dict and num_dict[second_num] != i: + return [i, num_dict[second_num]] \ No newline at end of file From e7839d54be8ed63d557b65c65bfc19346440efc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=80=E1=85=B5=E1=86=B7=E1=84=80=E1=85=A1=E1=84=8B?= =?UTF-8?q?=E1=85=B3=E1=86=AB?= Date: Tue, 1 Apr 2025 10:21:11 +0900 Subject: [PATCH 3/4] two-sum solution --- two-sum/paran22.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/two-sum/paran22.py b/two-sum/paran22.py index 5aed9b4b6..15d3ee9ce 100644 --- a/two-sum/paran22.py +++ b/two-sum/paran22.py @@ -6,4 +6,5 @@ def twoSum(self, nums: List[int], target: int) -> List[int]: for i, first_num in enumerate(nums): second_num = target - first_num if second_num in num_dict and num_dict[second_num] != i: - return [i, num_dict[second_num]] \ No newline at end of file + return [i, num_dict[second_num]] + \ No newline at end of file From 97b92bf296a96e70389a36d66a1d6eb0c0471965 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=80=E1=85=B5=E1=86=B7=E1=84=80=E1=85=A1=E1=84=8B?= =?UTF-8?q?=E1=85=B3=E1=86=AB?= Date: Tue, 1 Apr 2025 13:02:06 +0900 Subject: [PATCH 4/4] two-sum solution --- two-sum/paran22.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/two-sum/paran22.py b/two-sum/paran22.py index 15d3ee9ce..a95581372 100644 --- a/two-sum/paran22.py +++ b/two-sum/paran22.py @@ -7,4 +7,4 @@ def twoSum(self, nums: List[int], target: int) -> List[int]: second_num = target - first_num if second_num in num_dict and num_dict[second_num] != i: return [i, num_dict[second_num]] - \ No newline at end of file +