Problem Statement | |||||||||||||
A column diagram is composed of n consecutive columns arranged in a horizontal row. Each column has a width of 1, and the base of each column is on the x-axis. The heights of the columns are given in the int[] a, where a[i] is the height of the i-th column. The picture below shows an example of a column diagram:
Return the perimeter of the given column diagram. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Constraints | |||||||||||||
- | a will contain between 1 and 50 elements, inclusive. | ||||||||||||
- | Each element of a will be between 1 and 50, inclusive. | ||||||||||||
Examples | |||||||||||||
0) | |||||||||||||
| |||||||||||||
1) | |||||||||||||
| |||||||||||||
2) | |||||||||||||
| |||||||||||||
3) | |||||||||||||
| |||||||||||||
4) | |||||||||||||
|