Problem with code??.. getting wrong answers.
There is no node=6…but still i am getting it in the output…
Problem with code??.. getting wrong answers.
There is no node=6…but still i am getting it in the output…
Hi Parth,
Hi… is it clear now??
No…your code also not working. You have given no. of edges as 6…make it 7 and you will get a wrong answer.
Hi Parth,
Graph G(6) 6 over here doesn’t mean no of edges… it basically defines the no of vertices in my graph… and since have i have taken 0 based indexing the vertices in graph come out to be (0,1,2,3,4,5)… hope it clears ur doubt
But the problem with this approach is that if take number greater than 6…i am getting addtional nodes. I am asking how to fix that…?? You said use map…but still same problem.
for that what u can do is store all the nodes through which there is any edge in a set or something and while pushing in queue when u check indegree = 0 u would have to place an additional check if that node is present in the set or not which we used above…
ok…
shall i mark it as resolved now??
yeah…
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.