[seungbinpark] programmers_완주하지 못한 선수_Python - #7
Open
seungbinpark wants to merge 4 commits into
Open
Conversation
just-stopyoon
approved these changes
Jan 13, 2025
just-stopyoon
left a comment
Contributor
There was a problem hiding this comment.
주석까지 달아주신다면 코드가 훨씬 가독성이 좋지 않을까... 생각합니닷! 'ㅅ'
Contributor
There was a problem hiding this comment.
무궁무진한 파이썬 라이브러리의 세계 ... (역시 파이썬은 신이야)
새로운 클래스 Counter에 대해서 알 수 있었고, 이를 사용하니 훨씬 코드를 간결하게 작성할 수 있는 것 같아요!
sangkyu39
approved these changes
Jan 20, 2025
sangkyu39
left a comment
Collaborator
There was a problem hiding this comment.
counter 클래스를 활용하면 몇 번 나왔는지 확인하는 문제에서 다양하게 활용할 수 있을 것 같아서 좋네요!! 이번에 새로 알아갑니다!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🔗 문제 링크
https://school.programmers.co.kr/learn/courses/30/lessons/42576
문제
수많은 마라톤 선수 중 단 한 명의 선수를 제외하고는 모든 선수가 마라톤을 완주함
완주하지 못한 선수의 이름을 return
<제한사항>
💡 풀이 아이디어
처음에는 마지막 제한사항을 확인하지 못하고 코드를 작성했다.
아래는 딕셔너리를 활용해 작성한 코드이다.
📝 새로 학습한 내용
'Counter'는 파이썬의 'collections' 모듈에서 제공하는 클래스이다. 이는 해당 요소가 몇 번 등장했는지 세는 데 특화된 딕셔너리 형태의 자료구조이다.
<예>
'Counter(['a','b','b'])' -> '{'a' : 2, 'b': 1}'
Counter() 풀이
딕셔너리의 뺄셈을 이용하여 남은 'participant'의 key값이 완주하지 못한 선수가 되어 return하면 된다.
📚 참고 자료