You are given an integer array heights of length n.
A configuration of towers is defined as beautiful if it can be represented by an array result of length n that satisfies the following conditions:
result[i] heights[i] for all
result forms a mountain shape, meaning there exists a peak index
result[i] result[i + 1] for all
result[i] result[i + 1] for all
Return the maximum possible sum of heights among all beautiful tower configurations.
Constraints:
n heights.length
heights[i]
You are given an integer array heights of length n.
A configuration of towers is defined as beautiful if it can be represented by an array result of length n that satisfies the following conditions:
result[i] heights[i] for all
result forms a mountain shape, meaning there exists a peak index
result[i] result[i + 1] for all
result[i] result[i + 1] for all
Return the maximum possible sum of heights among all beautiful tower configurations.
Constraints:
n heights.length
heights[i]