-
Notifications
You must be signed in to change notification settings - Fork 1
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.
전체적으로 깔끔한 코드로 작성된 것 같아서 보기 편했습니다 고생하셨어요 도현님!
answer = [] | ||
|
||
for record in records: | ||
behavior, code, *user = record.split() |
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.
아 이렇게 빈 리스트도 받을 수 있군요 좋은 방식 감사합니다 도현님!
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.
오 저도 몰랐던 내용이네요! 하지만 협업할 때 이렇게 사용하기 위해서는 따로 명시를 해줘야 할 것 같아요 ㅎㅎ;;
from collections import defaultdict | ||
|
||
def solution(records): | ||
users = defaultdict() |
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.
굳이 defaultdict가 아니라 그냥 dict로 써줘도 될 것 같아요!
elif behavior == "Leave": | ||
answer.append([code, "님이 나갔습니다."]) | ||
|
||
for i in range(len(answer)): |
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.
여기서는 문제가 안되지만 원래 리스트를 순회하면서 리스트의 원소를 변경하는게 안전한 방법은 아니라 별도의 리스트를 사용하는 방법도 좋을 것 같아요! 고생하셨습니다 도현님~~!
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.
현재 순회중인 인덱스 이전의 원소만 업데이트 하는 건 크게 문제가 안될 것 같지만(dp문제에서 그러듯이), 만약 다시 현재 인덱스를 방문해야 하거나, 리스트 원소의 개수가 바뀌어 버리는 경우 안전하지 않은 게 맞습니다! 실제로 순회 중에 리스트 원소 개수가 바뀌면 에러납니다! 참고하시면 좋을 것 같아요.
answer = [] | ||
|
||
for record in records: | ||
behavior, code, *user = record.split() |
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.
오 저도 몰랐던 내용이네요! 하지만 협업할 때 이렇게 사용하기 위해서는 따로 명시를 해줘야 할 것 같아요 ㅎㅎ;;
elif behavior == "Leave": | ||
answer.append([code, "님이 나갔습니다."]) | ||
|
||
for i in range(len(answer)): |
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.
현재 순회중인 인덱스 이전의 원소만 업데이트 하는 건 크게 문제가 안될 것 같지만(dp문제에서 그러듯이), 만약 다시 현재 인덱스를 방문해야 하거나, 리스트 원소의 개수가 바뀌어 버리는 경우 안전하지 않은 게 맞습니다! 실제로 순회 중에 리스트 원소 개수가 바뀌면 에러납니다! 참고하시면 좋을 것 같아요.
PR Summary
풀이시간
접근법
회고
ISSUE NUMBER