-
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
[KwonNayeon] Week 5 #853
[KwonNayeon] Week 5 #853
Conversation
- 이 방식으로 각 시점에서 가능한 최대 이익을 계산함 | ||
|
||
To Do: | ||
- 다른 접근 방법 찾아보기 (Two Pointers, Dynamic Programming) |
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.
다른 접근 방법(Two Pointers, Dynamic Programming)을 고려해 보라고 주석에 적혀 있는데, 이 코드와 비교했을 때 어떤 장단점이 있을까요?
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.
@lledellebell 제약조건이 추가되었을 때를 고려해볼 수 있을 것 같습니다.
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.
@EgonD3V 조금 늦었지만, 답변 감사합니다!
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.
이번 주도 수고 많으셨습니다. 다음 주도 화이팅!
- 이 방식으로 각 시점에서 가능한 최대 이익을 계산함 | ||
|
||
To Do: | ||
- 다른 접근 방법 찾아보기 (Two Pointers, Dynamic Programming) |
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.
@lledellebell 제약조건이 추가되었을 때를 고려해볼 수 있을 것 같습니다.
def encode(self, strs): | ||
result = "" | ||
for s in strs: | ||
result = result + 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.
"#"같은 클래스의 다른 메서드에서도 사용하는 변수는 클래스 변수로 선언하고 사용하면 좋을 것 같습니다.
if sorted_str in anagram_dict: | ||
anagram_dict[sorted_str].append(s) | ||
else: | ||
anagram_dict[sorted_str] = [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.
if sorted_str in anagram_dict: | |
anagram_dict[sorted_str].append(s) | |
else: | |
anagram_dict[sorted_str] = [s] | |
anagram_dict[sorted_str] = anagram_dict.get(sorted_str, []) + [s] |
dict의 기본 내장 메서드를 이렇게 사용할 수도 있습니다
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.
리뷰 감사합니다! @EgonD3V 님 덕분에 조건문 없이 깔끔하게 코드를 구현하는 법을 배웠어요!
def __init__(self): | ||
# children은 "다음 글자들을 저장하는 공간" | ||
# 예: 'a' 다음에 'p'가 올 수 있다면 children['p']에 저장 | ||
self.children = {} | ||
|
||
# is_end는 "여기까지가 하나의 단어가 되는지"를 표시 | ||
# 예: "app"을 저장했다면, p노드의 is_end가 True | ||
self.is_end = False |
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.
TreeNode가 직접 값을 들고 있지 않고 children의 key로만 들고 있으면 나중에 Trie의 다른 조건이 포함된 조회 관련 메서드를 구현할 때 불편할 것 같습니다.
답안 제출 문제
체크 리스트
In Review
로 설정해주세요.