Breadth First Search: Shortest Reach

  • + 1 comment

    I had a similar problem using C# where test case 5 was reporting a wrong answer, and it was because of a missing edge. Funny thing was when I ran it in visual studio I was actually getting a key not found exception. I may not be hardcore, but it seems it maybe worthwhile to build up local test cases with debugging, as opposed to trying to debug in the website as I was doing for a couple of hours. Once I had my local test set up the problem became apparent in seconds, and I was able to upload the code and pass all of the tests.

    In writing this, it also occured to me that perhaps wrapping your code in a try catch mechanism and printing any exception message/stack to Console.Writeline would probably be helpful for debugging in the website directly, since the website doesn't seem to know in 100% of the cases where an exception was thrown.