diff --git "a/leetcode3/\354\227\274\355\230\234\354\240\225/463. Island Perimeter.java" "b/leetcode3/\354\227\274\355\230\234\354\240\225/463. Island Perimeter.java" new file mode 100644 index 000000000..6b18d183d --- /dev/null +++ "b/leetcode3/\354\227\274\355\230\234\354\240\225/463. Island Perimeter.java" @@ -0,0 +1,47 @@ +// 인접한 1의 개수를 구한다. +// 1 -> 3, 2 -> 2, 3 -> 1, 4 -> 0 + +class Solution { + static int[] dx = {-1, 1, 0, 0}; + static int[] dy = {0, 0, -1, 1}; + + public int islandPerimeter(int[][] grid) { + int sum = 0; + for (int i = 0; i= grid.length || ny >= grid[0].length) continue; + if (grid[nx][ny] == 1) cnt++; + } + return cnt; + } + + int calAdjacent(int num) { + switch (num) { + case 0: + return 4; + case 1: + return 3; + case 2: + return 2; + case 3: + return 1; + default: + return 0; + } + } +}