Skip to content
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

Merged
merged 4 commits into from
Jan 12, 2025
Merged

[suwi] Week 05 #866

merged 4 commits into from
Jan 12, 2025

Conversation

sungjinwi
Copy link
Contributor

@sungjinwi sungjinwi commented Jan 7, 2025

답안 제출 문제

체크 리스트

  • 우측 메뉴에서 PR을 Projects에 추가해주세요.
  • Projects의 오른쪽 버튼(▼)을 눌러 확장한 뒤, Week를 현재 주차로 설정해주세요.
  • 바로 앞에 PR을 열어주신 분을 코드 검토자로 지정해주세요.
  • 문제를 모두 푸시면 프로젝트에서 StatusIn Review로 설정해주세요.
  • 코드 검토자 1분 이상으로부터 승인을 받으셨다면 PR을 병합해주세요.

@sungjinwi sungjinwi requested a review from a team as a code owner January 7, 2025 11:52
@github-actions github-actions bot added the py label Jan 7, 2025
@sungjinwi sungjinwi requested a review from aa601 January 7, 2025 11:53
Copy link
Contributor

@EgonD3V EgonD3V left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이번 주도 수고하셨습니다 다음 주도 화이팅!

Comment on lines +26 to +32
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]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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}
Copy link
Contributor

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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

사실 이 문제는 위의 implement-trie-prefix-tree와 연계되는 문제여서 적용한 풀이법을 고민해보시면 좋을 것 같습니다

@aa601
Copy link
Contributor

aa601 commented Jan 12, 2025

문제마다 주석을 꼼꼼하게 달아주셔서 리뷰하면서 한번 더 공부할 수 있었어요! 이번 주도 고생 많으셨습니다. 다음 주차도 화이팅이에요👏

@TonyKim9401 TonyKim9401 merged commit f1f3e4e into DaleStudy:main Jan 12, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Completed
Development

Successfully merging this pull request may close these issues.

4 participants