Algorithm · Snapchat · Medium
You are given an m x n binary matrix grid. Each cell contains either a '1' (representing land) or a '0' (representing water). An island is a group of land cells connected horizontally or vertically (not diagonally). Every land cell has four edges. A particular edge adds to an island's perimeter if that edge borders water or if it lies on the outer boundary of the entire matrix. Your task is to return the largest perimeter among all islands present in the grid. Return 0 if no…
Checking your access…