From c00f407e92b4ee9a4a1b340c62f718241e5041c2 Mon Sep 17 00:00:00 2001 From: jinah92 Date: Fri, 20 Dec 2024 13:28:00 +0900 Subject: [PATCH 1/5] =?UTF-8?q?feat:=20valid-anagram=20=ED=92=80=EC=9D=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- valid-anagram/jinah92.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 valid-anagram/jinah92.py diff --git a/valid-anagram/jinah92.py b/valid-anagram/jinah92.py new file mode 100644 index 000000000..78c0e09f8 --- /dev/null +++ b/valid-anagram/jinah92.py @@ -0,0 +1,13 @@ +# 공간복잡도: O(n), 시간복잡도: O(n) +class Solution: + def isAnagram(self, s: str, t: str) -> bool: + char_set_1, char_set_2 = {}, {} + + for ch in s: + char_set_1[ch] = 0 if ch not in char_set_1 else char_set_1[ch] + 1 + + for ch in t: + char_set_2[ch] = 0 if ch not in char_set_2 else char_set_2[ch] + 1 + + # dictionary의 모든 요소 종류와 개수가 일치해야 함 + return char_set_1 == char_set_2 From 0bc32ec2261e065b1bd7218f65d31a5f471c428b Mon Sep 17 00:00:00 2001 From: jinah92 Date: Fri, 20 Dec 2024 14:07:33 +0900 Subject: [PATCH 2/5] =?UTF-8?q?feat:=20climbing-stairs=20=ED=92=80?= =?UTF-8?q?=EC=9D=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- climbing-stairs/jinah92.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 climbing-stairs/jinah92.py diff --git a/climbing-stairs/jinah92.py b/climbing-stairs/jinah92.py new file mode 100644 index 000000000..f38ea75b8 --- /dev/null +++ b/climbing-stairs/jinah92.py @@ -0,0 +1,12 @@ +# 공간복잡도: O(1), 시간복잡도: O(n) +class Solution: + def climbStairs(self, n: int) -> int: + if n < 3: + return n + + prev, curr = 1, 2 + for num in range(3, n+1): + prev, curr = curr, prev + curr + + return curr + \ No newline at end of file From a01d15d917611440d4a533320155e32b187c9837 Mon Sep 17 00:00:00 2001 From: jinah92 Date: Fri, 20 Dec 2024 16:27:17 +0900 Subject: [PATCH 3/5] =?UTF-8?q?feat:=203sum=20=EB=AC=B8=EC=A0=9C=ED=92=80?= =?UTF-8?q?=EC=9D=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 3sum/jinah92.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 3sum/jinah92.py diff --git a/3sum/jinah92.py b/3sum/jinah92.py new file mode 100644 index 000000000..ee378f668 --- /dev/null +++ b/3sum/jinah92.py @@ -0,0 +1,19 @@ +# 공간복잡도 : O(1), 시간복잡도 : O(N^2) +class Solution: + def threeSum(self, nums: List[int]) -> List[List[int]]: + three_sums = set() + nums.sort() + + for i in range(len(nums)-2): + low, high = i + 1, len(nums)-1 + while low < high: + three_sum = nums[i] + nums[high] + nums[low] + if three_sum < 0: + low += 1 + elif three_sum > 0: + high -= 1 + else: + three_sums.add((nums[i], nums[high], nums[low])) + low, high = low+1, high-1 + + return list(three_sums) From ec92d4d563db1adc2ad6cda2c41640556c614171 Mon Sep 17 00:00:00 2001 From: jinah92 Date: Fri, 20 Dec 2024 16:55:27 +0900 Subject: [PATCH 4/5] =?UTF-8?q?chore:=20=EA=B0=9C=ED=96=89=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 3sum/jinah92.py | 1 + valid-anagram/jinah92.py | 1 + 2 files changed, 2 insertions(+) diff --git a/3sum/jinah92.py b/3sum/jinah92.py index ee378f668..65e92ca91 100644 --- a/3sum/jinah92.py +++ b/3sum/jinah92.py @@ -17,3 +17,4 @@ def threeSum(self, nums: List[int]) -> List[List[int]]: low, high = low+1, high-1 return list(three_sums) + diff --git a/valid-anagram/jinah92.py b/valid-anagram/jinah92.py index 78c0e09f8..3187f7718 100644 --- a/valid-anagram/jinah92.py +++ b/valid-anagram/jinah92.py @@ -11,3 +11,4 @@ def isAnagram(self, s: str, t: str) -> bool: # dictionary의 모든 요소 종류와 개수가 일치해야 함 return char_set_1 == char_set_2 + From 969b9fb38ec1732dea143ae2efc55dddf9d2861f Mon Sep 17 00:00:00 2001 From: jinah92 Date: Fri, 20 Dec 2024 17:02:29 +0900 Subject: [PATCH 5/5] =?UTF-8?q?config:=20=EA=B0=9C=ED=96=89=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- climbing-stairs/jinah92.py | 1 - 1 file changed, 1 deletion(-) diff --git a/climbing-stairs/jinah92.py b/climbing-stairs/jinah92.py index f38ea75b8..b51d2cc84 100644 --- a/climbing-stairs/jinah92.py +++ b/climbing-stairs/jinah92.py @@ -9,4 +9,3 @@ def climbStairs(self, n: int) -> int: prev, curr = curr, prev + curr return curr - \ No newline at end of file