Shortest 11 Problem 300

WordPuzzle  

WordPuzzle

You are the mastermind behind a new word puzzle. The board you designed consists of filled spaces ('X') and empty spaces ('.'). 
Here is a sample 3x5 board:

..X..
...X.
X....

A "word slot" is defined as exactly N (>= 2) empty squares in a row, surrounded either by a filled space or the edge of the board. 
In the sample board above, there are 4 horizontal word slots:

Row 1: length 2
Row 1: length 2
Row 2: length 3
row 3: length 4

In order to make the game more interesting, you wish to balance the occurences of these word slots. In order to do so, you must 
find the length which has the most horizontal appearances. If two lenghts appear the same amount of times, you search for the 
one with the bigger length.

Given a board made out of strings, find and return the most re-occuring word length on the board.

Example:
	Given:	
	board = {"..X..", "...X.", "X...."}
	
	The response is 2 because the word slot with length 2 appears 2 times on the board.

Constraints:
	board will contain between 3 and 50 elements, inclusive.
	board rows will contain between 3 and 50 characters, inclusive.
	all board rows will be the same size.
	board contains only of '.' and 'X' characters.
	
Return value:
	The most re-occuring word length on th board.
Class Name:
  WordPuzzle

Method signature:
  public int getMostReoccuringLength(String[] board)

Test Case 1:
  getMostReoccuringLength({"X...................","XX...............XXX","XXXX............XXXX","XXXXXXXXXXXXXXX....X","X..............XXXXX","XX..................","XXXXXXXXXX.......XXX"}) = 19

Test Case 2:
  getMostReoccuringLength({"XXXXXXXXXXXXXXX...............XXXX","XXXXXXX.....................XXXXXX","XXXXXXXXXXXXXXXXXXXXXXXXXX.....XXX","XXXXX.............................","XXXXXXXXXXXXX.................XXXX","XXXXXXXXXX......................XX","XX..........................XXXXXX","XXXXXXXXXXXXX..................XXX","XXXXX.............XXXXXXXXXXXXXXXX",".................................X","XXX............................XXX","XXXXXX.....................XXXXXXX","XXXXXXX.................XXXXXXXXXX","XXXXXXXXXX...................XXXXX","X............................XXXXX","XX................................","XXXXXXXXX......................XXX","XXXX.....XXXXXXXXXXXXXXXXXXXXXXXXX","XX.....XXXXXXXXXXXXXXXXXXXXXXXXXXX","XX............................XXXX","XXXXXXXX.........XXXXXXXXXXXXXXXXX","................................XX","XXXXXX............XXXXXXXXXXXXXXXX","X.........................XXXXXXXX","XXXXXXXXXXXX..XXXXXXXXXXXXXXXXXXXX","XXXXXX.................XXXXXXXXXXX","XXX...............................","XXX......................XXXXXXXXX","XXXXXXXXXXXXXXXXXXXXXXXX...XXXXXXX","...........................XXXXXXX","XXXXXXXXX...................XXXXXX","XXXXXXXX.................XXXXXXXXX","XXXXXXXX..................XXXXXXXX","X................................."}) = 17

Test Case 3:
  getMostReoccuringLength({"XXX.......XX","XXXXX......X","XX........XX"}) = 8