Skip to content

Commit beb0a0e

Browse files
committed
96차 1번 문제풀이(실패)
1 parent abe211a commit beb0a0e

1 file changed

Lines changed: 29 additions & 3 deletions

File tree

live9/test96/문제1/조진우.js

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,32 @@
11
function solution(board) {
2-
var answer = 0;
2+
const h = board.length;
3+
const w = board[0].length;
4+
const map = board.map((row) => row.split(""));
5+
6+
let startX = -1;
7+
let startY = -1;
8+
9+
for (let i = 0; i < h; i++) {
10+
for (let j = 0; j < w; j++) {
11+
if (map[i][j] === "R") {
12+
startX = i;
13+
startY = j;
14+
break;
15+
}
16+
}
17+
}
18+
19+
const visited = Array.from({ length: h }, () => Array(w).fill(false));
20+
visited[startX][startY] = true;
21+
22+
const queue = [];
23+
queue.push([startX, startY]);
24+
25+
while (queue.length) {
26+
const [x, y] = queue.shift();
27+
for (let dir = 0; dir < 4; dir++) {}
28+
}
29+
30+
var answer = -1;
331
return answer;
432
}
5-
6-
console.log(solution(["...D..R", ".D.G...", "....D.D", "D....D.", "..D...."]));

0 commit comments

Comments
 (0)