← 返回 bytedance 的题目列表Trapping Rain Water Variant
类型:online_judge
Given a non-negative integer array representing the elevation map where the width of each bar is 1, compute how much water it can trap after raining.
Input Format:
An integer array that represents the elevation height map, with a length not exceeding 10^4.
Output Format:
An integer representing the maximum amount of water it can trap.
Test Cases:
Input: [0,1,0,2,1,0,1,3,2,1,2,1]; Output: 6
Input: [4,2,0,3,2,5]; Output: 9
Example
Input
6
0 1 0 2 1 0 1 3 2 1 2 1