Here is the approach:
Loop through every cell in the grid.
If the cell is land (), start with edges.
Check the neighbors (up, down, left, right). For each neighbor that is also land, subtract from the edge count.
Add the remaining edges to the total perimeter.
Return the total after visiting all cells.
This works because each land neighbor "hides" one edge. If a cell has land neighbors, only edge is exposed. The simplicity comes from the fact that there is only one island, so you do not need to track visited cells.