Skip to content

Commit 7e012a6

Browse files
refactor 419
1 parent d732a16 commit 7e012a6

File tree

1 file changed

+0
-32
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+0
-32
lines changed

src/main/java/com/fishercoder/solutions/_419.java

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,5 @@
11
package com.fishercoder.solutions;
22

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:
9-
10-
You receive a valid board, made of only battleships or empty slots.
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.
13-
At least one horizontal or vertical cell separates between two battleships - there are no adjacent battleships.
14-
15-
Example:
16-
17-
X..X
18-
...X
19-
...X
20-
21-
In the above board there are 2 battleships.
22-
23-
Invalid Example:
24-
25-
...X
26-
XXXX
27-
...X
28-
29-
This is an invalid board that you will not receive - as battleships will always have a cell separating between them.
30-
31-
Follow up:
32-
Could you do it in one-pass, using only O(1) extra memory and without modifying the value of the board?
33-
34-
*/
353
public class _419 {
364

375
public static class Solution1 {

0 commit comments

Comments
 (0)