This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* LINQ Puzzle #14 ******************************************************* | |
Summary: Given an array of integer, imagine they represent the cross section of some terrain with mountains and valleys. | |
It rains a bunch, but the ground isn't porous so the water fills up every valley as much as possible. Assuming the edges of | |
the array are the ends of the earth and water can exit there, how much total water fills the terrain? | |
Sample Input: { 4, 6, 5, 2, 0, 1, 3, 2, 4, 2 } | |
Sample Output: 12 | |
************************************************************************/ | |
var ints = new[] { 4, 6, 5, 2, 0, 1, 3, 2, 4, 2 }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment