int islandPerimeter(int** grid, int gridRowSize, int gridColSize) {

int count = 0;

```
for(int y = 0; y < gridRowSize; y++)
for(int x = 0; x < gridColSize; x++)
if (grid[y][x]) {
if (!y || !grid[y-1][x]) count++;
if (!x || !grid[y][x-1]) count++;
if (y + 1 == gridRowSize || !grid[y+1][x]) count++;
if (x + 1 == gridColSize || !grid[y][x+1]) count++;
}
return count;
```

}