Problem Statement | |||||||||||||
The king is trying to find new ways to generate revenue, and he is currently exploring tourism as one potential avenue. The kingdom is a group of islands, and the amount of revenue that can be generated depends on the combined total length of beaches on all the islands. You are given a String[] kingdom consisting of '.' or '#' characters. '#' represents a land mass, whereas '.' represents water. kingdom[i][j] represents a regular-hexagon shaped area with each side of unit length. Since the cells are hexagonal in shape, the odd-numbered rows (0-based) are 'shifted' towards the right. A beach is a segment which has water on one side, and land on the other. An example String[] and the corresponding image are given below to illustrate. The beaches are marked in red. {"..#.##", ".##.#.", "#.#..."} Return the combined total length of beaches on all the islands. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Constraints | |||||||||||||
- | kingdom will contain between 1 and 50 elements, inclusive. | ||||||||||||
- | Each element of kingdom will contain between 1 and 50 characters, inclusive. | ||||||||||||
- | Each element of kingdom will contain the same number of characters. | ||||||||||||
- | Each character in kingdom will be either '.' or '#'. | ||||||||||||
Examples | |||||||||||||
0) | |||||||||||||
| |||||||||||||
1) | |||||||||||||
| |||||||||||||
2) | |||||||||||||
| |||||||||||||
3) | |||||||||||||
|