-
-
Notifications
You must be signed in to change notification settings - Fork 195
[i-mprovising] Week 05 solution #1383
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
Conversation
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.
파이썬으로 깔끔하고 간단하게 문제 풀이하시는 부분이 인상깊었습니다!
이번 주도 고생하셨습니다 😃
min_price = prices[0] | ||
for p in prices: | ||
max_profit = max(max_profit, p - min_price) | ||
min_price = min(min_price, p) |
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.
저는 조건문을 통해서 min_price
를 설정해주었는데, min
을 통해 더 깔끔하게 풀이할 수 있다는 것 배워갑니다.
def groupAnagrams(self, strs: List[str]) -> List[List[str]]: | ||
group = defaultdict(list) | ||
for s in strs: | ||
sorted_str = str(sorted(s)) |
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.
sorted()
정렬이 포함되어 있는데 시간 복잡도를 O(n)
으로 적어주셔서, 이 부분이 의아하여 찾아보니 해설 에서도 O(wlog(w))
라고 적혀있었습니다.
파이썬에서 정렬의 성능이 O(n)
까지 나오는지 궁금합니다 🤔
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.
strs의 길이인 n을 기준으로 O(n)으로 작성을 했는데, 반복문 내에 단어를 정렬하는 것도 고려를 해야겠네요! 해당 부분 반영하여 시간 복잡도 수정했습니다.
확인 감사합니다!!
답안 제출 문제
작성자 체크 리스트
In Review
로 설정해주세요.검토자 체크 리스트
Important
본인 답안 제출 뿐만 아니라 다른 분 PR 하나 이상을 반드시 검토를 해주셔야 합니다!