[프로그래머스 연습문제 level_2 ] 게임 맵 최단거리
import java.util.*; class Solution { static int[][] D = {{-1,0},{1,0},{0,-1},{0,1}}; static int N, M; static class Point{ int row, col, dist; Point(int r, int c, int d){ row = r; col = c; dist = d; } } public int solution(int[][] maps) { int answer = 0; N = maps.length; M = maps[0].length; answer = bfs(maps, 0,0,N,M); return answer; } static int bfs(int[][] maps, int sRow, int sCol, int eRow, in..
2023. 11. 29.
[Sofreer 문제풀이] Lv.2(장애물 인식 프로그램) feat. Java
1. 장애물 인식 프로그램 import java.io.*; import java.util.*; public class Main { static class Point{ int row, col; Point(int r, int c){ row = r; col = c; } } static int[][] D = {{-1,0},{1,0},{0,-1},{0,1}}; // 행/열 위,아래,왼,오 static int N; static int[][] board; static int cntBlock = 0; static ArrayList arrCnt = new ArrayList(); static int blockNum; static boolean[][] visited; // dfs 함수 static void dfs(int r..
2023. 11. 2.