public static int countFill(int[] landscape, int start) {
        if (start >= landscape.length - 1) {
            return 0;
        }

        int startIndex = start;
        int endIndex = 0;

        int startHeight = landscape[start], endHeight = 0;

        for (int pos = start; pos < landscape.length; pos++) {

            // reached/exceeded original height?
            if ((pos > startIndex && landscape[pos] >= startHeight) || pos == landscape.length - 1) {
                endHeight = landscape[pos];
                endIndex = pos;
            }

            // falling again
            if (landscape[pos] < endHeight) {
                break;
            }
        }

        // now check how much water fits in the Dip
        int maxFill = Math.min(startHeight, endHeight);
        int volume = 0;
        for (int pos = startIndex; pos < endIndex; pos++) {
            int fill = maxFill - landscape[pos];
            if (fill > 0) {
                volume += fill;
            }
            // gap in the floor drains everything
            if (fill == maxFill) {
                volume = 0;
                break;
            }
        }

        return volume + countFill(landscape, endIndex);
    }