네트워크

    Programmers :: DFS(깊이 우선 탐색법) 네트워크 레벨 3

    풀이 import java.util.* class Solution { fun solution(n: Int, computers: Array): Int { val graph = Graph(n, computers) graph.buildEdge( graph.computersToRelationList() ) return graph.getNetworkSize() } } class Graph(n: Int, computers: Array) { val N: Int = n val adj = Array(N) { LinkedList() } val computers = computers fun buildEdge(relationList: List) { relationList.forEach { relation -> this.adj..

728x90