Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR implements a union‐find algorithm to solve a friend network problem by counting the size of each connected network after each union operation. Key changes include:
- Implementation of the union‐find functions with path compression.
- Initialization of friend and count maps for each test case.
- Direct output of the network size after each union operation.
Comments suppressed due to low confidence (2)
BaekJoon/4195/sungchan.py:14
- [nitpick] The lexicographical sorting here might not be immediately clear; consider adding a clarifying comment on why sorting by name is used for the union operation.
name1, name2 = (name2, name1) if name2 < name1 else (name1, name2) # 사전 순으로 정렬
BaekJoon/4195/sungchan.py:26
- [nitpick] The variable name 'friends' is used as the parent pointer map in the union-find structure; renaming it to something like 'parents' could more clearly convey its role.
friends = {}
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.
PR Summary
풀이 시간 : 20분
Union-Find 알고리즘이 바로 떠올랐지만, count 를 어떻게 하는지에서 헤맸다.