diff --git a/kjs254/README.md b/kjs254/README.md index 36c9ab2..211f377 100644 --- a/kjs254/README.md +++ b/kjs254/README.md @@ -11,3 +11,4 @@ | 9차시 | 2024.03.10 | 구현 | [뉴스 클러스터링](https://school.programmers.co.kr/learn/courses/30/lessons/17677) | [#33](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/33) | | 10차시 | 2024.04.02 | 해시 | [전화번호 목록](https://school.programmers.co.kr/learn/courses/30/lessons/42577) | [#46](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/46) | | 11차시 | 2024.04.05 | DFS | [타겟 넘버](https://school.programmers.co.kr/learn/courses/30/lessons/43165) | [#47](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/47) | +| 12차시 | 2024.04.11 | DFS | [안전지대](https://school.programmers.co.kr/learn/courses/30/lessons/120866) | [#50](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/50) | \ No newline at end of file diff --git "a/kjs254/\352\265\254\355\230\204/\354\225\210\354\240\204\354\247\200\353\214\200.py" "b/kjs254/\352\265\254\355\230\204/\354\225\210\354\240\204\354\247\200\353\214\200.py" new file mode 100644 index 0000000..75cc5d8 --- /dev/null +++ "b/kjs254/\352\265\254\355\230\204/\354\225\210\354\240\204\354\247\200\353\214\200.py" @@ -0,0 +1,17 @@ +def solution(board): + n = len(board) + for i in range(n): + board[i].insert(0,-1) + board[i].append(-1) + board.insert(0,[-1]*(n+2)) + board.append([-1]*(n+2)) + + for i in range(n+2): + for j in range(n+2): + + if board[i][j]==1: + for dx in (-1,0,1): + for dy in (-1,0,1): + board[i+dy][j+dx] = board[i+dy][j+dx]*2 -1 + + return sum(board, []).count(0) \ No newline at end of file