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
Tests:
Runtime:
Memory:
Test
Input:
Expected:
Got:
Click Run Code to test against sample cases, or Submit to test against all cases.
▲ Console