From c474203d39e29d932760f09ecaa3b6e1d5f1a99e Mon Sep 17 00:00:00 2001 From: kim heoung doon <63146721+chapse57@users.noreply.github.com> Date: Thu, 25 Jun 2026 10:54:19 +0900 Subject: [PATCH 1/3] Add contains-duplicate solution --- contains-duplicate/chapse57.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 contains-duplicate/chapse57.py diff --git a/contains-duplicate/chapse57.py b/contains-duplicate/chapse57.py new file mode 100644 index 0000000000..c0095bea02 --- /dev/null +++ b/contains-duplicate/chapse57.py @@ -0,0 +1,11 @@ +class Solution(object): + def containsDuplicate(self, nums): + """ + :type nums: List[int] + :rtype: bool + """ + for i in range(len(nums)): + for j in range(i+1,len(nums)): + if nums[i] == nums[j]: + return True + return False \ No newline at end of file From 9e5326588ed1fff68f172757534852a0bca14e26 Mon Sep 17 00:00:00 2001 From: kim heoung doon <63146721+chapse57@users.noreply.github.com> Date: Fri, 26 Jun 2026 17:05:47 +0900 Subject: [PATCH 2/3] [chapse57] Week 1 --- top-k-frequent-elements/chapse57.py | 20 ++++++++++++++++++++ two-sum/chapse57.py | 12 ++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 top-k-frequent-elements/chapse57.py create mode 100644 two-sum/chapse57.py diff --git a/top-k-frequent-elements/chapse57.py b/top-k-frequent-elements/chapse57.py new file mode 100644 index 0000000000..5288aecbc8 --- /dev/null +++ b/top-k-frequent-elements/chapse57.py @@ -0,0 +1,20 @@ +class Solution(object): + def topKFrequent(self, nums, k): + """ + :type nums: List[int] + :type k: int + :rtype: List[int] + """ + count = {} + for n in nums: + if n in count: + count[n] +=1 + else: + count[n] =1 + # count.items()를 횟수 큰 순으로 정렬 + freq = sorted(count.items(), key=lambda x: x[1], reverse=True) + + result = [] + for x in freq[:k]: + result.append(x[0]) + return result \ No newline at end of file diff --git a/two-sum/chapse57.py b/two-sum/chapse57.py new file mode 100644 index 0000000000..05cdae5612 --- /dev/null +++ b/two-sum/chapse57.py @@ -0,0 +1,12 @@ +class Solution(object): + def twoSum(self, nums, target): + """ + :type nums: List[int] + :type target: int + :rtype: List[int] + """ + seen = {} + for i in range(len(nums)): + if (target - nums[i]) in seen: + return [seen[target - nums[i]],i] + seen[nums[i]] =i \ No newline at end of file From 6895637d43f41a728ff014025121689beaef0384 Mon Sep 17 00:00:00 2001 From: kim heoung doon <63146721+chapse57@users.noreply.github.com> Date: Fri, 26 Jun 2026 17:34:37 +0900 Subject: [PATCH 3/3] fix: add final newline --- contains-duplicate/chapse57.py | 2 +- top-k-frequent-elements/chapse57.py | 4 +++- two-sum/chapse57.py | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/contains-duplicate/chapse57.py b/contains-duplicate/chapse57.py index c0095bea02..1cb32db06f 100644 --- a/contains-duplicate/chapse57.py +++ b/contains-duplicate/chapse57.py @@ -8,4 +8,4 @@ def containsDuplicate(self, nums): for j in range(i+1,len(nums)): if nums[i] == nums[j]: return True - return False \ No newline at end of file + return False diff --git a/top-k-frequent-elements/chapse57.py b/top-k-frequent-elements/chapse57.py index 5288aecbc8..99cd374eb8 100644 --- a/top-k-frequent-elements/chapse57.py +++ b/top-k-frequent-elements/chapse57.py @@ -17,4 +17,6 @@ def topKFrequent(self, nums, k): result = [] for x in freq[:k]: result.append(x[0]) - return result \ No newline at end of file + return result + + diff --git a/two-sum/chapse57.py b/two-sum/chapse57.py index 05cdae5612..b83b732ef1 100644 --- a/two-sum/chapse57.py +++ b/two-sum/chapse57.py @@ -9,4 +9,6 @@ def twoSum(self, nums, target): for i in range(len(nums)): if (target - nums[i]) in seen: return [seen[target - nums[i]],i] - seen[nums[i]] =i \ No newline at end of file + seen[nums[i]] =i + +