The Tilted Ledger of Skyport

Company: Inmobi_10oct

Difficulty: medium

Problem Statement

The Tilted Ledger of Skyport Problem Description Skyport has a straight row of n rain-terrace columns standing side by side. Every column is 1 unit wide, and column i (0-indexed) is height[i] units tall. An earthquake lifted the ground under the row along a straight slope s . If s > 0 the ground rises towards the right, if s < 0 it rises towards the left, and if s = 0 it stays flat. After the earthquake the top of column i is at H[i] = height[i] + s * i The adjusted height H[i] can be negative when s < 0 . Rain then fell overnight. Water settles on top of the columns exactly as in an ordinary row of bars: the water surface above column i can rise to level[i] = min(max(H[0..i]), max(H[i..n-1])) , where max(H[0..i]) is the tallest adjusted column from the left end up to i , and max(H[i..n-1]) is the tallest from i to the right end. Any water above the lower of those two walls spills over the side of the row. The earthquake also cracked the columns. Through the cracks, the gap ab