Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Sort the array <code>maximumHeight</code> in descending order.
After sorting, it can be seen that the maximum height that we can assign to the <code>i<sup>th</sup></code> element is <code>min(maximumHeight[i], maximumHeight[i - 1] - 1)</code>.