Skip to content
Open
11 changes: 11 additions & 0 deletions climbing-stairs/Yiseull.py

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🏷️ 알고리즘 패턴 분석

  • 패턴: Dynamic Programming
  • 설명: 피보나치 수열 형태의 중간 결과를 저장하여 큰 문제를 작은 문제로 나눠 해결하는 DP 패턴이 적용되어 있습니다. 각 단계의 해를 이전 두 값의 합으로 구합니다.

📊 시간/공간 복잡도 분석

ℹ️ 이 파일에는 2가지 풀이가 포함되어 있어 각각 분석합니다.

풀이 1: Solution.climbStairs — Time: O(n) / Space: O(n)
복잡도
Time O(n)
Space O(n)

피드백: 2 이상의 계단 수를 구하기 위해 dp 배열을 한 차례 순회하며 각 위치의 값을 계산합니다.

개선 제안: 현재 구현이 적절해 보입니다.

풀이 2: Solution.climbStairs — Time: O(n) / Space: O(n)
복잡도
Time O(n)
Space O(n)

피드백: n까지의 순회를 통해 모든 중간값을 보존하며 결과를 얻습니다.

개선 제안: 현재 구현이 적절해 보입니다.

💡 풀이에 시간/공간 복잡도를 주석으로 남겨보세요!

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class Solution:
def climbStairs(self, n: int) -> int:
if n == 1: return 1

dp = [0 for _ in range(n + 1)]
dp[0], dp[1] = 1, 1

for i in range(2, n + 1):
dp[i] = dp[i - 1] + dp[i - 2]

return dp[n]
15 changes: 15 additions & 0 deletions product-of-array-except-self/Yiseull.py

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🏷️ 알고리즘 패턴 분석

  • 패턴: Two Pointers, Dynamic Programming, Hash Map / Hash Set
  • 설명: 왼쪽 곱셈과 오른쪽 곱셈을 이용해 각 원소를 제외한 곱을 구하는 방식으로, 추가 배열에 누적 곱을 저장해 부분 문제를 해결한다. 두 방향으로 누적 곱을 계산하는 점에서 다이나믹 프로그래밍의 누적 상태 활용 패턴에 속한다.

📊 시간/공간 복잡도 분석

복잡도
Time O(n)
Space O(1)

피드백: 2회 순회를 통해 각 위치의 최종 곱을 계산하는 표준 접근으로 효율적이다.

개선 제안: 현재 구현이 적절해 보입니다.

💡 풀이에 시간/공간 복잡도를 주석으로 남겨보세요!

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class Solution:
def productExceptSelf(self, nums: List[int]) -> List[int]:
n = len(nums)
answer = [1]

# answer[i] -> nums[i] 왼쪽 값들의 곱
for i in range(1, n):
answer.append(answer[i - 1] * nums[i - 1])

tmp = 1
for i in range(n - 1, -1, -1):
answer[i] *= tmp
tmp *= nums[i]

return answer
5 changes: 5 additions & 0 deletions valid-anagram/Yiseull.py

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🏷️ 알고리즘 패턴 분석

  • 패턴: Hash Map / Hash Set, Greedy
  • 설명: Counter를 이용해 두 문자열의 문자 빈도를 비교하는 방식으로 해시 맵의 개념을 활용합니다. 간단한 동등성 비교이므로 그리디나 일반적인 해시 기반 비교로 분류할 수 있습니다.

📊 시간/공간 복잡도 분석

복잡도
Time O(n)
Space O(AlphabetSize)

피드백: Counter를 이용해 간단하고 직관적으로 구현됐다.

개선 제안: 현재 구현이 적절해 보입니다.

💡 풀이에 시간/공간 복잡도를 주석으로 남겨보세요!

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from collections import Counter

class Solution:
def isAnagram(self, s: str, t: str) -> bool:
return Counter(s) == Counter(t)
Loading