An array A containing heights of building was given. Its a rainy season. Calculate the amount of water collected between all the buildings.
The first line of input contains an integer T denoting the number of test cases. The first line of each test case is N, N is the number of buildings. The second line of each test case contains N input H[i],height of buildings.
Print the amount of water collected between all the buildings.
1 ≤ T ≤ 100
1 ≤ N ≤ 103
1 ≤ H[i] ≤ 103
1 5 3 7 4 2
Testcase 1: Water are trapped by block at index 2 (0-based indexing) only and can trap 2 units of water.
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.