프로그래머스/완전탐색
-
피로도프로그래머스/완전탐색 2025. 3. 25. 10:06
import java.util.*;class Solution { static boolean visit[]; static int max; public int solution(int k, int[][] dungeons) { int answer = -1; max = Integer.MIN_VALUE; visit = new boolean[dungeons.length]; // 탐험을 시작하는 함수 호출 (초기 탐험 횟수는 0) solve(k,dungeons, 0); answer = max; return answer; } ..
-
전력망을 둘로 나누기프로그래머스/완전탐색 2025. 3. 24. 22:05
import java.util.*;class Solution { static ArrayList[] graph; static int min; static boolean visit[]; public int solution(int n, int[][] wires) { graph = new ArrayList[n + 1]; // 노드 번호는 1부터 시작하므로 크기 n+1로 설정 min = Integer.MAX_VALUE; visit = new boolean[n+1]; // 그래프 ArrayList 초기화. 노드 개수만큼 ArrayList 생성 for (int i = 1; i (); }..