From a075497cacae666bcaeabf2a69572ab10b53e270 Mon Sep 17 00:00:00 2001 From: Seoya0512 Date: Thu, 8 Jan 2026 18:06:38 +0900 Subject: [PATCH 1/3] feat: week9 - linked list cycle --- linked-list-cycle/Seoya0512.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 linked-list-cycle/Seoya0512.py diff --git a/linked-list-cycle/Seoya0512.py b/linked-list-cycle/Seoya0512.py new file mode 100644 index 0000000000..2dde3a780c --- /dev/null +++ b/linked-list-cycle/Seoya0512.py @@ -0,0 +1,10 @@ +class Solution: + def hasCycle(self, head: Optional[ListNode]) -> bool: + cycle_set = set() + while head: + if head in cycle_set: + return True + cycle_set.add(head) + head = head.next + return False + \ No newline at end of file From 0b0ad1b4b38bed414450b23612a45dcee10f64b9 Mon Sep 17 00:00:00 2001 From: Seoya0512 Date: Fri, 9 Jan 2026 19:48:35 +0900 Subject: [PATCH 2/3] feat: week9 - maximum product subarray --- maximum-product-subarray/Seoya0512.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 maximum-product-subarray/Seoya0512.py diff --git a/maximum-product-subarray/Seoya0512.py b/maximum-product-subarray/Seoya0512.py new file mode 100644 index 0000000000..6b565b4aab --- /dev/null +++ b/maximum-product-subarray/Seoya0512.py @@ -0,0 +1,19 @@ +''' +이전 곱을 저장해서 곱셈 연산을 줄이는 방식 +해당 연산 방식은 Time Limited Exceeded 오류를 발생했습니다. + +시간 복잡도: O(n^2) +- 외부 for-loop과 내부 for-loop이 각각 n번씩 실행되기 때문 +공간 복잡도: O(1) +''' +class Solution: + def maxProduct(self, nums: List[int]) -> int: + max_product = nums[0] + + for i in range(len(nums)): + prev = 1 + for j in range(i, len(nums)): + prev = prev * nums[j] + max_product = max(max_product, prev) + + return max_product \ No newline at end of file From 9effdd5a82143528ba67439b8c595db574b656a0 Mon Sep 17 00:00:00 2001 From: Seoya0512 Date: Fri, 9 Jan 2026 19:51:10 +0900 Subject: [PATCH 3/3] =?UTF-8?q?fix:=20=EC=8A=A4=ED=8E=98=EC=9D=B4=EC=8A=A4?= =?UTF-8?q?=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- linked-list-cycle/Seoya0512.py | 1 - maximum-product-subarray/Seoya0512.py | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/linked-list-cycle/Seoya0512.py b/linked-list-cycle/Seoya0512.py index 2dde3a780c..3cad5460c2 100644 --- a/linked-list-cycle/Seoya0512.py +++ b/linked-list-cycle/Seoya0512.py @@ -7,4 +7,3 @@ def hasCycle(self, head: Optional[ListNode]) -> bool: cycle_set.add(head) head = head.next return False - \ No newline at end of file diff --git a/maximum-product-subarray/Seoya0512.py b/maximum-product-subarray/Seoya0512.py index 6b565b4aab..c26f4ea59e 100644 --- a/maximum-product-subarray/Seoya0512.py +++ b/maximum-product-subarray/Seoya0512.py @@ -16,4 +16,4 @@ def maxProduct(self, nums: List[int]) -> int: prev = prev * nums[j] max_product = max(max_product, prev) - return max_product \ No newline at end of file + return max_product