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.
Have you thought about what the time complexity is of your approach?
I see you are running a lot of BFS's in a loop.Ok, that seems to be alright, because there's only one character in the grid that's A. Another concern is the many maps you are using for storing info. They give an extra log factor, with quite a big constant. Try changing them to arrays.Thanks a lot, brother. I have done everything according to your suggestion and my code got accepted. Here is my Accepted Code
Thanks, I got stuck on the same.
So Happy to know that, This blog is still helpful. Some months ago, I thought of deleting this blog. Glad that, I didn't delete the blog.