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

[KwonNayeon] Week 5 #853

Merged
merged 9 commits into from
Jan 12, 2025
Merged

[KwonNayeon] Week 5 #853

merged 9 commits into from
Jan 12, 2025

Conversation

KwonNayeon
Copy link
Contributor

@KwonNayeon KwonNayeon commented Jan 5, 2025

답안 제출 문제

체크 리스트

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

@KwonNayeon KwonNayeon requested a review from a team as a code owner January 5, 2025 23:18
@github-actions github-actions bot added the py label Jan 5, 2025
- 이 방식으로 각 시점에서 가능한 최대 이익을 계산함

To Do:
- 다른 접근 방법 찾아보기 (Two Pointers, Dynamic Programming)
Copy link
Contributor

Choose a reason for hiding this comment

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

다른 접근 방법(Two Pointers, Dynamic Programming)을 고려해 보라고 주석에 적혀 있는데, 이 코드와 비교했을 때 어떤 장단점이 있을까요?

Copy link
Contributor

Choose a reason for hiding this comment

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

@lledellebell 제약조건이 추가되었을 때를 고려해볼 수 있을 것 같습니다.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@EgonD3V 조금 늦었지만, 답변 감사합니다!

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.

이번 주도 수고 많으셨습니다. 다음 주도 화이팅!

- 이 방식으로 각 시점에서 가능한 최대 이익을 계산함

To Do:
- 다른 접근 방법 찾아보기 (Two Pointers, Dynamic Programming)
Copy link
Contributor

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 + "#"
Copy link
Contributor

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 +29
if sorted_str in anagram_dict:
anagram_dict[sorted_str].append(s)
else:
anagram_dict[sorted_str] = [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
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의 기본 내장 메서드를 이렇게 사용할 수도 있습니다

Copy link
Contributor Author

Choose a reason for hiding this comment

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

리뷰 감사합니다! @EgonD3V 님 덕분에 조건문 없이 깔끔하게 코드를 구현하는 법을 배웠어요!

Comment on lines +37 to +44
def __init__(self):
# children은 "다음 글자들을 저장하는 공간"
# 예: 'a' 다음에 'p'가 올 수 있다면 children['p']에 저장
self.children = {}

# is_end는 "여기까지가 하나의 단어가 되는지"를 표시
# 예: "app"을 저장했다면, p노드의 is_end가 True
self.is_end = False
Copy link
Contributor

Choose a reason for hiding this comment

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

TreeNode가 직접 값을 들고 있지 않고 children의 key로만 들고 있으면 나중에 Trie의 다른 조건이 포함된 조회 관련 메서드를 구현할 때 불편할 것 같습니다.

@TonyKim9401 TonyKim9401 merged commit 1bfe1f3 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