#3301

Maximize the Total Height of Unique Towers

expert · 1050 · lc medium +32 · 37.3% accepted · 129 likes · top 15%

Description

You are given integer array maximumHeight where maximumHeight[i] is the max allowed height of tower i. Assign each tower a positive integer height not exceeding its maximum, with all heights distinct.

Return the maximum possible total height sum, or -1 if impossible.

Code

1
2
3