Count Vessels in a Service-Footprint Grid

An ocean-monitoring team stores a service footprint as a rectangular grid. A 1 marks a tile occupied by a section of vessel, while a 0 marks open water. Sections belonging to one vessel touch through an edge: north, south, east, or west. Diagonal contact does not join sections.

Return the number of distinct vessels in the footprint. The input grid is supplied as an array of equal-length strings. Your function may use a working copy while exploring the footprint, but it must not count the same vessel twice.

Examples
Input: ["0110","0110","0001"]
Output: 2
Hints
Related Problems

Count Vessels in a Service-Footprint Grid

An ocean-monitoring team stores a service footprint as a rectangular grid. A `1` marks a tile occupied by a section of vessel, while a `0` marks open water. Sections belonging to one vessel touch through an edge: north, south, east, or west. Diagonal contact does not join sections.