Comments

can you define some algo for string construction as the value of m is quite large so we cannot iterate over it.

OK thanks

Thank you so much man, but can you tell me how changing grid[i][j] != '#' to grid[i][j] == '.'. is decreasing the required time.