Skip to content

Instantly share code, notes, and snippets.

@ssartell
Created April 26, 2019 20:48
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
/* 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