LinkedIn tech test question: Reach The End in Time

Please tell me how to solve this. got this in yesterday's LinkedIn Software Developer Tech test
Although i can solve it but My code is not so clean and i dont know if that is the right way to do it. so It would be great if provide me full code
!
image
image

Also An another input was
2
.#
#.
4
output: No

Comments (3)