Skip to content

[2025-04-01] sungchan #452#453

Open
sungchan1 wants to merge 1 commit intomainfrom
sungchan-#452
Open

[2025-04-01] sungchan #452#453
sungchan1 wants to merge 1 commit intomainfrom
sungchan-#452

Conversation

@sungchan1
Copy link
Copy Markdown
Collaborator

PR Summary

풀이 시간 : 20분
Union-Find 알고리즘이 바로 떠올랐지만, count 를 어떻게 하는지에서 헤맸다.

image

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 = {}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants