I have tried different times in different ways to execute an accepted solution but Alas, everytime I failed. I would be eternally grateful if someone could debug my code and say what and where I should change in my code so that I won't get TLE. Here is my code Geting TLE in 1000 x 1000 grids Thanks a lot in advance.