[Baekjoon-2606] jeongbeen #162
Open
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.
전에 풀었던 문제라서 이번엔 Union Find 로 문제를 풀어봤습니다.
루트 노드의 정보를 1차원 배열에 저장해놓고 간선의 정보가 추가될 때마다 루트 노드의 정보를 업데이트 하는 방법입니다.
두 노드의 루트 노드가 같다면 이미 같은 집합에 속해 있다는 뜻이고, 같지 않다면 더 작은 루트 노드의 값으로 업데이트 합니다. (루트 노드 탐색 시간 낭비를 방지하기 위해)