← 返回 microsoft 的题目列表Rainwater trapping problem variant
类型:online_judge
Given an array representing the heights of bars at each position, calculate the maximum water that can be trapped. Note that the initially provided solution is not optimal, and may time out on some unseen test cases due to insufficient algorithm speed.
Example
Input
[0,1,0,2,1,0,1,3,2,1,2,1]
Output
6