diff --git a/code_study/Baekjoon/ts/1987.ts b/code_study/Baekjoon/ts/1987.ts new file mode 100644 index 0000000..045b9b1 --- /dev/null +++ b/code_study/Baekjoon/ts/1987.ts @@ -0,0 +1,35 @@ +export {}; + +const input: string[] = require("fs").readFileSync(0).toString().trim().split('\n'); +const [R, C]: number[] = input[0].split(' ').map(Number); + +let board: string[][] = []; +for(let i=1; i<=R; i++) { + board.push(input[i].split('')); +} + +let alphabet: boolean[] = new Array(26).fill(false); +alphabet[board[0][0].charCodeAt(0) - 65] = true; +let maxStep: number = 1; + +const dx: number[] = [1,-1,0,0]; +const dy: number[] = [0,0,1,-1]; + +const dfs = ([cx, cy, cs]: number[]) => { + maxStep = Math.max(cs, maxStep); + + for(let i=0; i<4; i++) { + const nx = cx + dx[i]; + const ny = cy + dy[i]; + + if(0<=nx && nx