Count Land Regions in a Grid

Asked at Bridgewater · Coding Questions · Difficulty: Medium

Given a 2D grid of `'1'`s (land) and `'0'`s (water), count the islands. An island is a maximal group of land cells connected horizontally or vertically; diagonal neighbours are not connected. Treat everything outside the grid as water.

Loading the problem…