[LeetCode/Java] Surrounded Regions
·
문제 풀이
해석 적기import java.util.LinkedList;import java.util.Queue;class Solution { static int[] dx = {1, 0, -1, 0}; static int[] dy = {0, 1, 0, -1}; public void solve(char[][] board) { int rows = board.length, cols = board[0].length; Queue queue = new LinkedList(); // Step 1: 경계에 있는 'O'를 찾아 큐에 추가하고 'T'로 변경 for (int i = 0; i queue) { queue.add(new int[]{x, y}); ..