We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
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.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Breadth First Search: Shortest Reach
You are viewing a single comment's thread. Return to all comments →
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.