Counting Land Regions on a Grid Map

Asked at Illumio · Coding Questions · Difficulty: Medium

A survey map is stored as a grid of characters, where `'1'` marks land and `'0'` marks water. Land cells that touch along an edge (up, down, left or right) belong to the same land region; cells that touch only at a corner do not. Count how many separate land regions the map contains.

Loading the problem…