Skip to content
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

공간 복잡도를 O(1)으로 최적화할 수 있을 것 같습니다!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

변수 2개로도 충분히 풀 수 있군요! 피드백 감사합니다~!

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, Two Pointers
  • 설명: 피보나치 수열과 유사한 점화식을 이용해 각 단계의 값을 현재 값의 합으로 갱신하는 DP 접근이다. 공간 절약을 위해 두 변수로만 상태를 유지하는 방식은 Two Pointers의 변형으로 볼 수 있다.

📊 시간/공간 복잡도 분석

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

피드백: 상수 개수의 변수를 이용해 순차적으로 계단 수를 갱신한다.

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

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

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.

answer[0]을 1로 할당하니까 로직이 잘 읽히네요. 잘 봤습니다.

공간/시간 복잡도를 코드에 적어주시면 좋을 것 같아요!

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.

🏷️ 알고리즘 패턴 분석

  • 패턴: Prefix / Suffix Product, Dynamic Programming, Two Pointers
  • 설명: 주석과 구현에서 왼쪽 곱셈과 오른쪽 곱셈을 합쳐 결과를 구하는 패턴으로, 부분 문제의 곱을 왼쪽·오른쪽 누적 곱으로 구성하는 DP 스타일이다. 입력 배열을 한 번 순회하고 역방향 누적 곱으로 최종 결과를 구한다.

📊 시간/공간 복잡도 분석

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

피드백: 두 패스로 누적 곱을 이용해 추가 공간 없이 해결한다.

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

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

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):

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.

개인적으로 저는 이렇게 작성하는거를 선호합니다!

for i in reversed(range(n)):

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.

파이썬의 언어적인 특성을 잘 활용하신 것 같습니다!

저는 성능에 도움이 될 것 같아서, 아래와 같이 길이가 다를 경우 얼리리턴을 해주었습니다. 참고 부탁드립니다~

if len(s) != len(t):
  return False

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, Dynamic Programming
  • 설명: 주어진 코드는 문자열의 문자 빈도를 비교하기 위해 해시 맵(카운터)을 사용합니다. 두 문자열의 카운트가 같으면 같은 구성임을 확인하는 간단한 비교로 패턴은 해시 맵 활용에 해당합니다. 추가적으로 길이 비교로 빠른 실패를 적용합니다.

📊 시간/공간 복잡도 분석

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

피드백: 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