3301. Maximize the Total Height of Unique Towers
You are given an array
maximumHeight, wheremaximumHeight[i]denotes the maximum height theithtower can be assigned.Your task is to assign a height to each tower so that:
- The height of the
ithtower is a positive integer and does not exceedmaximumHeight[i].- No two towers have the same height.
Return the maximum possible total sum of the tower heights. If it’s not possible to assign heights, return
-1.
1 | class Solution { |