[20251105] PGM / LV2 / 도넛과 막대 그래프 / 김민진 #1321
Merged
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.
🧷 문제 링크
도넛과 막대 그래프
🧭 풀이 시간
60분
👀 체감 난이도
✏️ 문제 설명
막대, 도넛, 8자 그래프의 갯수 세기
임의의 정점이 각 도넛의 임의의 노드를 가리킴
그래프 갯수는 2개 이상
🔍 풀이 방법
bfs 돌면서 간선 수, 노드 수 비교로 도넛과 8자 그래프 판단
-> 나가는 간선 수 2개이면 8자 그래프
-> 방문 처리된 노드를 발견했을 때 거쳐온 노드와 간선의 수가 같으면 도넛, 간선이 더 많으면 8(8은 나가는 간선이 2개인 노드가 있기 때문)
막대 그래프는 자식노드가 없는 노드가 있는 경우
그래프가 2개 이상이라고 해서 부모노드가 없고 자식 노드가 2개 이상인 경우가 임의의 노드
-> 막대그래프 중간에 임의의 간선이 연결되면 막대그래프의 최상단 노드도 부모노드가 없음
⏳ 회고
프로그래머스 너무 불편한데..