re: shouting
@wallhackio What is IIFE?
re: shouting
@vaporeon_ a special javascript syntax that lets you declare and execute a function simultaneously :DDDDD
re: shouting
@vaporeon_ IT'S BEAUTIFUL 🥹
/**
* @param {character[][]} grid
* @return {number}
*/
var numIslands = function(grid) {
const seen = new Set;
const R = grid.length, C = grid[0].length;
let count = 0;
for (let x = 0; x < R; ++x)
for (let y = 0; y < C; ++y)
if (!seen.has(`${x}-${y}`) && grid[x][y] === '1')
(function crawl(grid, x, y, seen) {
if (x < 0 || x >= R || y < 0 || y >= C) return;
const key = `${x}-${y}`;
if (seen.has(key)) return;
seen.add(key);
if (grid[x][y] === '0') return;
crawl(grid, x + 1, y, seen);
crawl(grid, x, y + 1, seen);
crawl(grid, x - 1, y, seen);
crawl(grid, x, y - 1, seen);
})(grid, x, y, seen), count++;
return count;
};
re: shouting
@vaporeon_ reported.