Problem Statement | |||||||||||||
The diamond game is played on a rectangular board, each cell of which is either empty or occupied by a diamond. First, you remove one arbitrary diamond from the board. Then, you continuously remove diamonds from cells that are vertically or horizontally adjacent to at least one cell from which you have previously (any time before) removed a diamond . Do this until you can no longer remove any more diamonds. Your goal is to remove as many diamonds as possible. At the beginning of the game, you have an extra diamond in your hand. You can optionally place it in any one of the empty cells before you start playing the game. The game board is given as a String[] diamondsBoard, where each cell is marked with a '*' or '.'. A '*' represents a cell occupied by a diamond and a '.' represents an empty cell. You are to return the maximum number of diamonds you can remove not including the extra diamond. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Constraints | |||||||||||||
- | diamondsBoard will contain between 1 and 50 elements, inclusive. | ||||||||||||
- | Each element of diamondsBoard will contain between 1 and 50 characters, inclusive. | ||||||||||||
- | Each element of diamondsBoard will contain the same number of characters. | ||||||||||||
- | Each character in each element of diamondsBoard will be either '*' or '.'. | ||||||||||||
Examples | |||||||||||||
0) | |||||||||||||
| |||||||||||||
1) | |||||||||||||
| |||||||||||||
2) | |||||||||||||
| |||||||||||||
3) | |||||||||||||
| |||||||||||||
4) | |||||||||||||
| |||||||||||||
5) | |||||||||||||
| |||||||||||||
6) | |||||||||||||
|