One Test Case is failing

One test case is failing.
please tell me what’s goes wrong.

Also Tell me. I am trying to solve using dp but only one test case passed by that way.

for this input

10
......#...
..........
........#.
.......##.
..........
..........
..........
..........
..........
..........

correct Output is 3
but your code output is 4

try to counter this case as well

Reference Code

Please tell me the logic behind it

try to dry run this
you will understand it well

logic is nearly same
Logic:

This logic is completely different.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.