Code not working

My code seems to work when i just take 1 test case but gives the wrong out put when i use 2 test cases.
code-https://ide.codingblocks.com/s/345592

Hey @amanb25
Clear graph like this :

for(int i=0;i<N;i++)
{
graph[i].clear();
}

Currently u are clearing graph[0] multiple times
auto x:graph will traverse elements of graph[0]

Also some testcases will still not pass ,for that use long long

Hello I changed my code to this-https://ide.codingblocks.com/s/345592… still 2 test cases don’t pass

…

than you! it works!!

1 Like