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.
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
- Class:
- Islands
- Method:
- beachLength
- Parameters:
- String[]
- Returns:
- int
- Method signature:
- int beachLength(String[] kingdom)
- (be sure your method is public)
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
{".#...#.."}Returns: 4
There are two small islands with water on two sides of each island.{"..#.##", ".##.#.", "#.#..."}Returns: 19
The example in the problem statement.{"#...#.....", "##..#...#."}Returns: 15
{"....#.", ".#....", "..#..#", "####.."}Returns: 24