Back to problems

Beautiful Towers II

Algorithm · Expedia · Hard

Problem: Beautiful Towers II You receive a 0-indexed integer array maxHeights containing n elements. Construct n towers along a number line, placing tower i at coordinate i and assigning it a height of heights[i]. The arrangement heights is beautiful when both conditions hold: Each position i satisfies 1 <= heights[i] <= maxHeights[i]. The heights form a mountain array: there is some index peak such that: For every 0 < j <= peak, heights[j - 1] <= heights[j]. For every peak…

Checking your access…