-
-
Notifications
You must be signed in to change notification settings - Fork 245
[kayden] Week 05 Solutions #448
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
Changes from 4 commits
cdb6714
136a246
38f42a2
483f9c3
41e0e8c
3d2514c
83f14be
f415907
e23a34e
fdbc181
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# 시간복잡도: O(N) | ||
# 공간복잡도: O(1) | ||
class Solution: | ||
def maxProfit(self, prices: List[int]) -> int: | ||
|
||
answer = 0 | ||
cur = float(inf) | ||
for price in prices: | ||
if cur < price: | ||
answer = max(answer, price - cur) | ||
|
||
if price < cur: | ||
cur = price | ||
|
||
return answer |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# 시간복잡도: O(N*AlogN) A: 0<= strs[i]의 길이 <= 100 | ||
# 공간복잡도: O(N) | ||
class Solution: | ||
def groupAnagrams(self, strs: List[str]) -> List[List[str]]: | ||
groups = {} | ||
for anagram in strs: | ||
key = str(sorted(anagram)) | ||
groups.setdefault(key, []).append(anagram) | ||
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.
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. @obzva 같이 읽어보시면 도움이 될 만한 글 추천드려요. 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. 이런 좋은 블로그가 있네요 ^~^ |
||
|
||
return list(groups.values()) |
Uh oh!
There was an error while loading. Please reload this page.