diff --git "a/leetcode3/\355\231\251\354\235\200\354\247\200/385. Mini Parser.js" "b/leetcode3/\355\231\251\354\235\200\354\247\200/385. Mini Parser.js" new file mode 100644 index 000000000..79e0d2e4c --- /dev/null +++ "b/leetcode3/\355\231\251\354\235\200\354\247\200/385. Mini Parser.js" @@ -0,0 +1,46 @@ +/** + * // This is the interface that allows for creating nested lists. + * // You should not implement it, or speculate about its implementation + * function NestedInteger() { + * + * Return true if this NestedInteger holds a single integer, rather than a nested list. + * @return {boolean} + * this.isInteger = function() { + * ... + * }; + * + * Return the single integer that this NestedInteger holds, if it holds a single integer + * Return null if this NestedInteger holds a nested list + * @return {integer} + * this.getInteger = function() { + * ... + * }; + * + * Set this NestedInteger to hold a single integer equal to value. + * @return {void} + * this.setInteger = function(value) { + * ... + * }; + * + * Set this NestedInteger to hold a nested list and adds a nested integer elem to it. + * @return {void} + * this.add = function(elem) { + * ... + * }; + * + * Return the nested list that this NestedInteger holds, if it holds a nested list + * Return null if this NestedInteger holds a single integer + * @return {NestedInteger[]} + * this.getList = function() { + * ... + * }; + * }; + */ +/** + * @param {string} s + * @return {NestedInteger} + */ +var deserialize = function (s) { + const nested = NestedInteger(s); + return nested.getInteger(); +}; diff --git "a/leetcode3/\355\231\251\354\235\200\354\247\200/463. Island Perimeter.js" "b/leetcode3/\355\231\251\354\235\200\354\247\200/463. Island Perimeter.js" new file mode 100644 index 000000000..8493bcbbe --- /dev/null +++ "b/leetcode3/\355\231\251\354\235\200\354\247\200/463. Island Perimeter.js" @@ -0,0 +1,49 @@ +/** + * @param {number[][]} grid + * @return {number} + */ +var islandPerimeter = function(grid) { + + const ROW=grid.length; + const COL=grid[0].length; + + //BFS + function doBFS(startR,startC){ + const DIR=[[-1,0],[0,1],[1,0],[0,-1]] + const visited=Array.from({length:ROW},()=>Array(COL)); + let count=0; + + visited[startR][startC]=true; + + const queue=[[startR,startC]]; + let head=0; + + while(head=ROW || nextC<0 || nextC>=COL + || grid[nextR][nextC]===0){ + count++; + continue; + } + if(visited[nextR][nextC]) continue; + visited[nextR][nextC]=true; + queue.push([nextR,nextC]); + } + } + return count; + + } + + + // 실행부 + for(let i=0;i