Given a grid of 1s (land) and 0s (water) containing exactly one island (connected 4-directionally, no lakes), return the perimeter of the island. The input is JSON {grid}.
Input: JSON {grid}.
Output: Integer — the island perimeter.
Input: {"grid":[[0,1,0,0],[1,1,1,0],[0,1,0,0],[1,1,0,0]]}
Output: 16
Explanation: Total exposed edges.Input: {"grid":[[1]]}
Output: 4
Explanation: A single cell has 4 sides.Input: {"grid":[[1,1]]}
Output: 6
Explanation: Two adjacent cells share one edge.1<=rows,cols<=100