[프로그래머스/자바] 쿼드압축 후 개수 세기
class Solution { private static int[] answer = new int[2]; public int[] solution(int[][] arr) { dq(0, 0, arr.length, arr); return answer; } private static void dq(int dx, int dy, int size, int[][] arr) { if (check(dx, dy, size, arr)) { answer[arr[dx][dy]]++; return; } dq(dx, dy, size / 2, arr); dq(dx + size / 2, dy, size / 2, arr); dq(dx, dy + size / 2, size / 2, arr); dq(dx + size / 2, dy + siz..
[프로그래머스/자바] 거리두기 확인하기
import java.util.*; class Solution { class Point { int row, col, dtc; Point(int row, int col, int dtc) { this.row = row; this.col = col; this.dtc = dtc; } } private static final int[][] D = {{1,0}, {-1,0}, {0,1}, {0,-1}}; private boolean bfs(String[] place, int x, int y) { boolean[][] visited = new boolean[5][5]; Queue q = new LinkedList(); visited[x][y] = true; q.add(new Point(x, y, 0)); while ..