No need for dynamic programming in this question. Just throw light from east and then from south.
Indexes which recieved light from both east and south will have count 2. Rest will have count 0(initial) or 1(just from 1 side). Blocks are numbered 99.
While throwing light if you occur a 99/block stop the light else continue in that row or column.
At end count all blocks with count==2 and that is the answer.