Practice Beautiful Towers I
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
You are given an array heights of n integers representing the number of bricks in n consecutive towers. Your task is to remove some bricks to form a mountain-shaped tower arrangement. In this arrangement, the tower heights are non-decreasing, reaching a maximum peak value with one or multiple consecutive towers and then non-increasing. Return the maximum possible sum of heights of a mountain-shaped tower arrangement.
Source: Beautiful Towers I on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
heights = [5,3,4,1,1]
13
# Example 2
heights = [6,5,3,9,2,7]
22
# Example 3
heights = [3,2,5,5,2,3]
18
Constraints
Related LeetCode Problems
Practice more problems similar to Beautiful Towers I.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.