30-Days-DSA-Challenge icon indicating copy to clipboard operation
30-Days-DSA-Challenge copied to clipboard

2865. Beautiful Towers I

Open docjon09 opened this issue 1 year ago • 2 comments

Description

Greedy

DSA Problem

You are given a 0-indexed array maxHeights of n integers.

You are tasked with building n towers in the coordinate line. The ith tower is built at coordinate i and has a height of heights[i].

A configuration of towers is beautiful if the following conditions hold:

1 <= heights[i] <= maxHeights[i] heights is a mountain array. Array heights is a mountain if there exists an index i such that:

For all 0 < j <= i, heights[j - 1] <= heights[j] For all i <= k < n - 1, heights[k + 1] <= heights[k] Return the maximum possible sum of heights of a beautiful configuration of towers.

docjon09 avatar Oct 13 '23 10:10 docjon09

Please assign this issue to me.

docjon09 avatar Oct 13 '23 10:10 docjon09

Hello! Please Assign it to me. I would like to contribute.

AdarshKannarath avatar Oct 18 '23 09:10 AdarshKannarath