Waterflow Problem

The array 2 5 3 4 3 2 5 5 3 4 2 2 2 represents the hill below.

If it rains in the hill, 9 units of water accumulate. (Water is assumed to run off the edges.)

Given the hill represented by the array below, how many units of water will accumulate?

hill = [4, 2, 4, 1, 5, 3, 16, 6, 17, 19, 4, 13, 5, 3, 10, 10, 13, 6, 2, 1, 5, 15,
        13, 19, 16, 9, 13, 1, 7, 18, 20, 13, 9, 7, 2, 10, 8, 18, 4, 7, 5, 8, 10, 13, 
        7, 18, 19, 2, 19, 8, 10, 10, 17, 6, 6, 20, 20, 11, 10, 11, 13, 9, 7, 1, 10, 
        5, 12, 16, 10, 7, 15, 13, 12, 10, 1, 1, 4, 2, 16, 10, 20, 17, 11, 19, 19, 20, 
        9, 10, 17, 9, 18, 8, 10, 18, 8, 19, 16, 17, 3, 1]

×

Problem Loading...

Note Loading...

Set Loading...