Some interesting code snippets gathered from various sources (work of mine).
Cubed Water Volumn
We have a board of NxM square (1x1) cells where each cell may have a non-uniform height of x.
Write a program that outputs the total volume of standing water the board can hold after submerged underwater and lifted back out. One can assume when lifting the board out no water is spilled.
For example given a board where each number below represents the cell height
4 3 3 4 2 3 4 1 4 4 4 4
The volume returned for this board is: 3 units cubed
4 3 3 4 2 3 4 1 1 4 4 4
The volume returned for this board is: 0 units cubed