-
-
Notifications
You must be signed in to change notification settings - Fork 247
[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
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
2bfced8
valid anagram
Do-heewan 13a5cdf
climbing stairs
Do-heewan 787e651
Update do-heewan.py
Do-heewan 49866af
Delete do-heewan.py
Do-heewan 2bbec85
Create do-heewan.py
Do-heewan ff3372c
Update do-heewan.py
Do-heewan ecc9a93
Update do-heewan.py
Do-heewan 8fb26d6
Create do-heewan.py
Do-heewan 1e85511
Update do-heewan.py
Do-heewan 4e5be4e
Update do-heewan.py
Do-heewan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = [] | ||
|
||
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 | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 간단하고 직관적인 풀이로 하지만 Counter 이용에 대한 아이디어도 한 번은 생각해보시길 바랍니다 :) |
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
저는 배열을 여러개 이용해서 풀어서 공간 복잡도가 높아지는 문제점이 있었는데, do-heewan님처럼 이렇게 하나의 배열로 간단하게 해결할 수 있다는 인사이트 얻고 가요. 이번주도 고생 많으셨습니다!