heights of positive integers, the heights of some columns. You may rearrange the columns in any order and trim any column down to a smaller positive integer height, as many times as you like.
The final row must be tidy: the first column has height 1, and any two neighbouring columns differ in height by at most 1.
Return the greatest height a column can have in such a tidy row.heights=[7, 1, 3, 3] → 4
Arrange them as 1, 3, 3, 7 and trim to 1, 2, 3, 4. The tallest is 4.
heights=[2, 2, 2, 2] → 2
The first column has to be cut to 1, the rest can stay at 2: 1, 2, 2, 2.
heights=[1000000000] → 1
The only column is first in the row, so it must become 1.
heights.length ≤ 10⁵heights[i] ≤ 10⁹heights=[7, 1, 3, 3]
4
Run checks the first 3 tests in your browser. Submit checks all 137 tests on the server, hidden ones included.