#2865

Beautiful Towers I

specialist · 965 · lc medium +32 · 44.4% accepted · 363 likes · top 27%

Description

An array heights of n integers gives the number of bricks in each of n consecutive towers. Remove bricks to create a mountain-shaped arrangement: heights are non-decreasing up to a peak, then non-increasing.

Return the maximum total height sum achievable.

Code

1
2
3