You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
/**Given an 2D board, count how many battleships are in it. The battleships are represented with 'X's, empty slots are represented with '.'s. You may assume the following rules:
3
+
/**
4
+
* 419. Battleships in a Board
5
+
*
6
+
* Given an 2D board, count how many battleships are in it.
7
+
* The battleships are represented with 'X's, empty slots are represented with '.'s.
8
+
* You may assume the following rules:
4
9
5
10
You receive a valid board, made of only battleships or empty slots.
6
-
Battleships can only be placed horizontally or vertically. In other words, they can only be made of the shape 1xN (1 row, N columns) or Nx1 (N rows, 1 column), where N can be of any size.
11
+
Battleships can only be placed horizontally or vertically.
12
+
In other words, they can only be made of the shape 1xN (1 row, N columns) or Nx1 (N rows, 1 column), where N can be of any size.
7
13
At least one horizontal or vertical cell separates between two battleships - there are no adjacent battleships.