Skip to content

[JiHyeonSu] WEEK 2 solutions #1271

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 3 commits into from
Apr 13, 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
21 changes: 21 additions & 0 deletions climbing-stairs/JiHyeonSu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# 피보나치 수열
# DP Bottom-up
# 시간복잡도 및 공간복잡도 O(n)

class Solution:
def climbStairs(self, n: int) -> int:
if (n < 2):
return n

dp = [0] * (n + 1)

dp[1] = 1
dp[2] = 2

first, second = 1, 2

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

return dp[n]

17 changes: 17 additions & 0 deletions product-of-array-except-self/JiHyeonSu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
class Solution:
def productExceptSelf(self, nums: List[int]) -> List[int]:
n = len(nums)
answer = [1] * n

left = 1
for i in range(n):
answer[i] = left
left *= nums[i]

right = 1
for i in reversed(range(n)):
answer[i] *= right
right *= nums[i]

return answer

7 changes: 7 additions & 0 deletions valid-anagram/JiHyeonSu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# 재배치하여 다른 문자를 만들 수 있는지 여부
# 시간복잡도 / 공간복잡도 O(n)

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