We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 0556fe3 + 9effdd5 commit 37291eeCopy full SHA for 37291ee
linked-list-cycle/Seoya0512.py
@@ -0,0 +1,9 @@
1
+class Solution:
2
+ def hasCycle(self, head: Optional[ListNode]) -> bool:
3
+ cycle_set = set()
4
+ while head:
5
+ if head in cycle_set:
6
+ return True
7
+ cycle_set.add(head)
8
+ head = head.next
9
+ return False
maximum-product-subarray/Seoya0512.py
@@ -0,0 +1,19 @@
+'''
+이전 곱을 저장해서 곱셈 연산을 줄이는 방식
+해당 연산 방식은 Time Limited Exceeded 오류를 발생했습니다.
+
+시간 복잡도: O(n^2)
+- 외부 for-loop과 내부 for-loop이 각각 n번씩 실행되기 때문
+공간 복잡도: O(1)
10
+ def maxProduct(self, nums: List[int]) -> int:
11
+ max_product = nums[0]
12
13
+ for i in range(len(nums)):
14
+ prev = 1
15
+ for j in range(i, len(nums)):
16
+ prev = prev * nums[j]
17
+ max_product = max(max_product, prev)
18
19
+ return max_product
0 commit comments