|All-time Popular Problems|
|Check if subtree|
|Delete Middle of Linked List|
|Given a linked list of 0s, 1s and 2s, sort it.|
|Count nodes of linked list|
|Delete N nodes after M nodes of a linked list|
|Check for Balanced Tree|
|Remove every k'th node|
|k largest elements|
|0 - 1 Knapsack Problem|
|Subarray with given sum|
Given n non-negative integers in array representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.
2 0 2
Structure is like below
We can trap 2 units of water in the middle gap.
Below is another example.
The first line of input contains an integer T denoting the number of test cases. The description of T test cases follows.
Each test case contains an integer N followed by N numbers to be stored in array.
Print trap units of water in the middle gap.
7 4 0 9
6 9 9