Company: Inmobi_10oct
Difficulty: medium
The Tilted Ledger of Skyport Problem Description There is a long row of rain-terrace columns in Skyport, where the width of each column is 1 and the height of the i th column is height[i] . An earthquake occurred, which caused the ground to rise, hence columns also rose along with it. Some of the columns got cracks as well. Ground can rise from either left or right in a slope s . If s > 0 , the ground rises to the right. If s , it rises to the left. The new height of columns due to this slope can be calculated as: H[i] = height[i] + s * i After overnight rain, due to the gaps in the columns, some rainwater remained trapped in the morning. Since there were cracks in the columns as well due to the earthquake, it limits the amount of water that the gaps in the columns can hold after rain. The maximum amount of water the gap above the i-th column can hold due to cracks in adjacent columns causing the leak is represented by cap[i] . You are given: n — number of columns in a straight line s