Sort 10 Discussions, By:
Please Login in order to post a comment
i am having a wrong answer with 5th and 6th test case but others are working could you tell me what problem could i be making?
Weight can also be euqal to zero.
For me, optimised Prim's with min priority queue worked.
Wrong answer on test cases 5 and 6 with two different implementations of the Prim's algorithm using Java 8: https://github.com/veniva/algo-minimal-network
why are comments blocked on problem 106?
can someone help me?
I implemented using C language.
when i take MAX N to be 3000. it shows segmentation fault and when i take it as 2000 it works fine.
what could be the problem...
Multiple edges must not be allowed in the testcases as they are not allowed in an adjacency matrix.
Either don't use an adjacency matrix, or do the trivial removal of the larger edge (i.e. keep the only the smaller one)
Hi guys, I can't pass test case #7 using C#. Is anyone willing to review my code? Thanks.
I'm unable to beat the time limit on challenge 4, 5 and 6 using python 2.7. I've optimized all I could think of, managed to get my code down to 24 lines of code including comments, to no avail.
I implemented the Prim's Algorithm as explained by Barry Brown on youtube. I believe I may have narrowed the bottleneck down to one line of code, but without one of the bigger challenges' data I'm out of luck I think.
Challenges 4,5 and 6 where easily accepted (all under 0.5s using python 3) using Prim's algorithm. I don't know why you are trying to minimize lines of code. It's way better to have a lisible and efficient code. Note that you can keep a heap of all potential edges to add to the tree to efficiently retrieve the minimum one.
I am not trying to minimize the lines of code, I am trying to reduce the amount of unnecessary statements and overhead. I do keep a heap of candidates, though keeping track of the minimum candidate appears to be just as good of an approach. I'll keep tinkering. Thanks.
Just for info, my code is 28 lines long. If you want, you can send me your code, so I will be able to maybe point an ineffcient part.
yeah accepted in first attempt with 0.00 s
No more comments