Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
20 changes: 20 additions & 0 deletions climbing-stairs/daehyun99.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, Greedy
  • 설명: 주어진 코드는 피보나치 형태의 계단 오르기 문제를 다양한 조합으로 세는 방식으로 구현되며, DP의 기본 아이디어(부분 문제의 합)와 탐색적 접근(그리디형으로 특정 단계의 선택 분기)을 통해 해를 구한다.

📊 시간/공간 복잡도 분석

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

피드백: 각 단계의 경우의 수를 상태로 유지해 빠르게 누적하는 방식으로 구현되었으나, 현재 구현은 직관적이지 않을 수 있다.

개선 제안: 속도와 가독성을 위해 간단한 피보나치 DP로 구현하거나, 공간을 더 절약하는 형태로 개선해 보세요.

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
class Solution:
def climbStairs(self, n: int) -> int:
one_count = n
two_count = 0
total_count = 0

while one_count >=0 and two_count >=0:
# 조합
total = one_count + two_count

count = 1
for i in range(two_count):
count *= total - i
for i in range(two_count, 0, -1):
count /= i
total_count += count

one_count -=2
two_count +=1
Comment on lines +2 to +19

@parkhojeong parkhojeong Jul 4, 2026

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.

dp를 사용하시면 arr[i] = arr[i-1] + arr[i-2] 과 같이 직관적인 코드로 개선해볼 수 있을 거 같습니다!

return int(total_count)
16 changes: 16 additions & 0 deletions valid-anagram/daehyun99.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.

collections 의 Counter가 기본적으로 defaultdict(int) 처럼 없는 키값에 대해 0을 보낸다는것을 알고 계실까요?
그걸 쓰시면 훨씬 간단하게 작성하실수 있으실거에요!

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.

Counter는 해시 가능 객체를 세기 위한 dict 서브 클래스입니다.

@alphaorderly
오호 코테 풀면서 Counter을 자세히 알아본 적은 없었는데, dict의 한 종류였군요!
많이 유용할 것 같아요. 코멘트 감사합니다!

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, Two Pointers, Greedy
  • 설명: 두 문자열의 문자 빈도를 해시맵으로 합 비교하는 방식으로 동작하며, 서로 다른 문자의 개수를 빠르게 확인해 후보를 제거합니다. 두 포인터처럼 zip으로 한 글자씩 짝을 맞추는 느낌도 있습니다.

📊 시간/공간 복잡도 분석

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

피드백: 카운트 차이를 이용해 한 번의 순회로 결과를 판정한다. 간단하고 빠른 방법이다.

개선 제안: 필요 없을 때는 defaultdict 사용 대신 배열 인덱스 기반 카운트로 더 빠르게 구현 가능.

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from collections import defaultdict
class Solution:
def isAnagram(self, s: str, t: str) -> bool:
count = defaultdict(int)

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

for s_, t_ in zip(s, t):
count[s_] += 1
count[t_] -= 1

for key, val in count.items():
if val != 0:
return False
return True
Loading