728x90
네트워크
-
프로그래머스 (Level 3) - 네트워크Coding Test/Coding Test 문제 풀이 2022. 1. 26. 17:27
문제 설명 코딩테스트 연습 - 네트워크 네트워크란 컴퓨터 상호 간에 정보를 교환할 수 있도록 연결된 형태를 의미합니다. 예를 들어, 컴퓨터 A와 컴퓨터 B가 직접적으로 연결되어있고, 컴퓨터 B와 컴퓨터 C가 직접적으로 연결되어 있 programmers.co.kr 풀이 연결된 컴퓨터에 대한 정보로 그래프를 생성한 후 DFS 또는 BFS 알고리즘을 사용해서 그래프 내 네트워크의 개수를 구하면 되는 문제이다. /* 그래프의 각 노드에 대한 정보를 정의 */ class Node { int data; // 노드의 번호 ArrayList adjacents; // 인접한 노드들 boolean visited; // 방문 여부 Node(int data) { this.data = data; this.adjacents = ..