-
Notifications
You must be signed in to change notification settings - Fork 126
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
[suwi] Week 05 #866
[suwi] Week 05 #866
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.
이번 주도 수고하셨습니다 다음 주도 화이팅!
anagrams = defaultdict(list) | ||
for s in strs: | ||
sorted_s = "".join(sorted(s)) | ||
if sorted_s in anagrams: | ||
anagrams[sorted_s].append(s) | ||
else: | ||
anagrams[sorted_s] = [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.
anagrams = defaultdict(list) | |
for s in strs: | |
sorted_s = "".join(sorted(s)) | |
if sorted_s in anagrams: | |
anagrams[sorted_s].append(s) | |
else: | |
anagrams[sorted_s] = [s] | |
anagrams = {} | |
for s in strs: | |
sorted_s = "".join(sorted(s)) | |
anagrams[sorted_s] = anagrams.get(sorted_s, []) + [s] |
defaultdict를 안쓰고 dict의 내장 메서드를 쓰는 방법도 있어 공유드립니다
class Trie: | ||
|
||
def __init__(self): | ||
self.root = {"ending":True} |
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.
"ending"같은 문자열을 고정적으로 사용한다면 클래스 변수로 선언하여 상수로 사용하는 편이 좋을 것 같습니다
""" | ||
|
||
class Solution: | ||
def wordBreak(self, s: str, wordDict: List[str]) -> bool: |
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.
사실 이 문제는 위의 implement-trie-prefix-tree와 연계되는 문제여서 적용한 풀이법을 고민해보시면 좋을 것 같습니다
문제마다 주석을 꼼꼼하게 달아주셔서 리뷰하면서 한번 더 공부할 수 있었어요! 이번 주도 고생 많으셨습니다. 다음 주차도 화이팅이에요👏 |
답안 제출 문제
체크 리스트
In Review
로 설정해주세요.