JAVA_Island Perimeter_LeetCode 463 풀이 class Solution { public int islandPerimeter(int[][] grid) { int cnt=0; for(int i = 0;i < grid.length;i++){ for(int j = 0;j < grid[i].length;j++){ if(grid[i][j] == 1){ cnt+=4; if(i > 0 && grid[i-1][j] == 1) cnt-=2; if(j > 0 && grid[i][j-1] == 1) cnt-=2; } } } return cnt; } } * 출처 Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com...
#IslandPerimeter_LeetCode463
#JAVA
#JAVA_IslandPerimeter
#JAVA_IslandPerimeter_LeetCode463
#JAVA_LeetCode463
원문링크 : JAVA_Island Perimeter_LeetCode 463