I think your second data set is wrong because cycles like (5,2) are not allowed according to the problem description.
Thanks this helped me fix the issue. In my case I did a mistake my topological sort implementation.
Thank you, you helped me with this user case.
For me it was the search of ârootâ which was incorrect. So i was using the wrong root, so ofc i get a wrong diameter (i used ânode 1â instead of ânode 9â).
Hi,
my solution doesnât pass the test cases, however it passes all the tests when I submit. I think the problem (or the tests, might be poorly designed)
Hi ! Does anyone know what the âArbitrary indexesâ test is about? This is the only one failing for me, and I have no idea whyâŚthanks!
Hi there, I passed the tests but I see there is âmemoizationâ specified as a hint to this puzzle, I canât figure out how it would be used here, any idea to share with me?
I can understand that several influence paths will reach a node with different pathSoFar lengths, so stopping the walk when weâve already reached a node with a bigger previous path length makes sense, but this is more related to caching than memoization, isnât it?
Well, basically, memoization is a peculiar case of caching.
Ok ahah, just wanted to be sure Iâm not missing anything.
I am sorry. I pass all the recommended test given in the above comments but always cannot pass the test âMore complex hierarchyâ. I donât know what the problem is.
Hereâs the validator âMore complex hierarchyâ:
Input:
8
6 4
6 5
1 3
2 1
2 3
5 4
3 5
2 4
Output:
5
Thanks a lot, Thibaud! The test case helped me to solve out the problem.
I have also blocked by this test case and then I have recognized that a single author may be influenced by multiple authors (i.e. a single node in the graph might have multiple parents with different path-length).
It would be nice to have a developer test case covering this situation
yes, there should be test cases that are relevant to the validators.
Not sure why it still hasnât been done.
A new test case has been added regarding the âMore complex hierarchyâ validator, you should be able to successfully fail this one .
I confirm, it successfully fails (Several mentors 2 test case) :
Console output
Standard Output Stream:
Unable to open output file: No such file or directory
/tmp/Tester.sh: line 8: in4.txt: No such file or directory
Failure
Found: Nothing
Expected: Nothing
EDIT : In fact on this test this behavior is not systematic, but it often happens.
It should be fixed by now
YEAHH!!! thank you very much sir , my algo is forward & backward searching
Same for me.
Test âmore complex hierarcyâ fails KO
(1,2),(2,3),(2,4),(3,4),(4,5) gives me 5 as a result OK
I know itâs years later, but thanks, this got me on the right track.
My false thought was that the highest numbered node must be a child, not a parent âŚ
Hi ! i pass everything except for âArbitrary indexâ, i read this topic and someone said it was for large number in input, but after some updgrading still doesnt pass. @TwoSteps could u please share the validator so i can test on my machine and debug the code ? Thank you very much !