Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
38 changes: 38 additions & 0 deletions climbing-stairs/Yu-Jaeyoung.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Time Complexity: O(n)
# Space Complexity: O(1)
# With 1 <= n <= 45, all counts fit within a 32-bit signed integer.
# Approach: Build each count by adding the previous two counts.
#
# Solution history
# 1. Counted arrangements using C(n - k, k) for each possible k.
# 2. Replaced combination calls with additions of the previous two counts.
# Keeps only two values. Current solution.
class Solution:
def climbStairs(self, n: int) -> int:
if n <= 2:
return n

prev, curr = 1, 2

for _ in range(3, n + 1):
prev, curr = curr, prev + curr

return curr


# Previous solution (Attempt 1: Combinations)
# Time Complexity: O(n)
# Space Complexity: O(1)
# These bounds assume 1 <= n <= 45, where CPython's math.comb
# uses fixed-size integer fast paths and all values remain small.
#
# from math import comb
#
# class Solution:
# def climbStairs(self, n: int) -> int:
# step = 0
# for k in range(n // 2 + 1):
# step += comb(n - k, k)
#
# return step
Comment on lines +23 to +37

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

기존 풀이를 조합으로 접근하신 게 새롭네요!
저는 피보나치 수열 1, 2, 3, 5, 8, ...처럼 접근하였는데
2칸을 k번 밟으면 1칸은 n - 2k번이니, 총 이동 횟수 n - k번 중 2칸을 밟을 자리 k개를 고르는 방식으로 접근하셨네요

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.

확률과 통계를 기억하며 조합으로 풀이해봤습니다 !
깔끔하게 풀리더라구요 😃


20 changes: 20 additions & 0 deletions valid-anagram/Yu-Jaeyoung.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Time: O(n + m) on average, Space: O(1)
# n = len(s), m = len(t); at most 26 distinct lowercase letters.
class Solution:
def isAnagram(self, s: str, t: str) -> bool:
count_s = {}
for char in s:
if char in count_s:
count_s[char] += 1
else:
count_s[char] = 1
Comment on lines +7 to +10

@Chaewon-Park-STUDY Chaewon-Park-STUDY Nov 16, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

저라면 원래 이 부분을 count_s[char] = count_s.get(char, 0) + 1로 줄였을 텐데,
지난 주차에 다른 분께 리뷰를 받고 defaultdict(int)를 쓰면 get 없이 count_s[char] += 1 한 줄로 if/else를 대신할 수 있다는 걸 알게 되었습니다
이렇게 직접 활용되는 걸 보니, 서로 다른 풀이를 비교하고 점검하는 게 안목을 기르는 데 정말 도움이 많이 되는 것 같네요 :)

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.

남은 주간 저도 열심히 리뷰해보겠습니다.
좋은 말씀 감사합니다 ⭐


count_t = {}
for char in t:
if char in count_t:
count_t[char] += 1
else:
count_t[char] = 1

return count_s == count_t
Comment on lines +5 to +19

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

안녕하세요:)
저는 ord(문자) - ord('a')로 인덱스를 구해 정적배열을 활용하였는데, char를 그대로 key로 쓰셔서 더 직관적이라 좋아 보이네요~!

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.

Python이 익숙하지 않아 ord 함수가 무엇인지 찾아보았네요 .. 🤣
참고하겠습니다 !


Loading