Given an array A where each element denotes a the height of blocks, calculate the total volume of water that can be trapped when it rains.
Note: one cubic block has a volume of 1 unit.
A: [ 1, 0, 2, 1, 0, 1, 3, 2, 1, 2, 1 ]
The total volume of water is 1 + 3 + 1 + 1 = 6 units.
First-line contains an integer ‘T’ denoting the number of test cases.
For each test-case the input has two lines:
For each test case, the output has a line with an integer ‘w’ denoting the volume of trapped rainwater.
2
5
1 0 0 1 0
6
1 0 2 0 0 1
2
3
1 <= T <= 100
1 <= n <= 30000
0 <= Ai <= 104