Battleships in a Board

Medium
Arrays Array Matrix DFS

Count battleships on a board. X=ship, .=empty.

Constraints

m, n ≤ 200

Examples

Example 1:
Input: X . . X . . . X . . . X
Output: 2
▲ Console

Install Talent Arabia

Get instant access to jobs and career tools on your device.