Skip to content

[do-heewan] WEEK 2 solutions #1748

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Aug 2, 2025
Merged
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
11 changes: 11 additions & 0 deletions climbing-stairs/do-heewan.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class Solution:
def climbStairs(self, n: int) -> int:
dp = [0] * 46
dp[1] = 1
dp[2] = 2

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

return dp[n]

16 changes: 16 additions & 0 deletions product-of-array-except-self/do-heewan.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class Solution:
def productExceptSelf(self, nums: List[int]) -> List[int]:
result = []
Copy link
Contributor

Choose a reason for hiding this comment

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

저는 배열을 여러개 이용해서 풀어서 공간 복잡도가 높아지는 문제점이 있었는데, do-heewan님처럼 이렇게 하나의 배열로 간단하게 해결할 수 있다는 인사이트 얻고 가요. 이번주도 고생 많으셨습니다!


x = 1
for element in nums:
result.append(x)
x *= element

x = 1
for i in range(len(nums)-1, -1, -1):
result[i] *= x
x *= nums[i]

return result

4 changes: 4 additions & 0 deletions valid-anagram/do-heewan.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class Solution:
def isAnagram(self, s: str, t: str) -> bool:
return sorted(s) == sorted(t)
Copy link
Contributor

Choose a reason for hiding this comment

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

간단하고 직관적인 풀이로 하지만 Counter 이용에 대한 아이디어도 한 번은 생각해보시길 바랍니다 :)