# [Common Mistake] What is the answer for this input?

• What is the answer for the following input ?
[
[12,13,1,12],
[13,4,13,12],
[13,8,10,12],
[12,13,12,12],
[13,13,13,13]
]

Here is what I think the amount of water stored above each cell should be:
0 0 0 0
0 9 0 0
0 4 2 0
0 0 0 0
0 0 0 0

So ans is 9 + 4 + 2 = 15. It seems that OJ expects the answer to be 14. What am I missing?

• Never mind, I found the mistake. I found that this is a common newbie mistake for this question and some others also faced difficulties in understanding this. So I will try to explain.

The problem is that the value at [1][1] should be 8 and not 9.

If you look only at the walls, then you will see that there are walls of size 13 and so the answer should be 9. However, notice the value at [2][1], it is 12 and not 13 and it is not possible to have 13 at [1][1] but 12 at [2][1] as extra water will flow out from [1][1] to [2][1] and then to the left and right of [2][1].

Hope it helps in understanding the problem better.

• still don't understand why is the result 14,I think it should be 15

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.