You are going to repair an old fence. The fence consists of several consecutive boards, some of which are broken and some of which are fine. The boards are numbered from left to right in increasing order. To repair all the boards between i and j, inclusive, where j is greater than or equal to i, a woodworker charges sqrt(j-i+1), where sqrt is the square root function. Due to the woodworker's pricing scheme, it is often necessary to repair boards even if they are not broken in order to get the best price (see examples).
You will be given a String[] boards. Concatenate the elements of boards to create a single string representing the fence from left to right. Broken boards are represented by 'X' characters and good boards are represented by '.' characters. Return the minimal cost required to repair all broken boards.
|