Problem · Array
Unequal Block Structure
Learn this problemProblem statement
You are given two arrays, heights and cost, of equal length. You may increase the height of block i by any nonnegative integer number of units. Each unit added to that block costs cost[i].
Choose the increases so that no two adjacent blocks have equal final heights. Return the minimum possible total cost.
Function
getMinCost(heights: int[], cost: int[]) → longExamples
Example 1
heights = [2, 2, 3]cost = [4, 1, 5]return = 2Increase the second block by 2 units. The final heights become [2, 4, 3], and the total cost is 2 * 1 = 2.
Constraints
1 <= heights.length = cost.length <= 2 * 10^61 <= heights[i], cost[i] <= 10^9