@vivek96 If you just call the dfs function once then it will only perform dfs in one component of the graph.
If there are more than one components then we will have to iterate and run dfs starting from other vertices too.
@vivek96 If you just call the dfs function once then it will only perform dfs in one component of the graph.
If there are more than one components then we will have to iterate and run dfs starting from other vertices too.
sorry,its not your fault but im unable to understand the concept of components.feeling bad!
DFS : to identify a single component.
Re-iteration of the loop : to find out the nodes which are not connected to the previous component found out and search again.
@shraeyas Sorry I wasn’t able to figure out the bug but seems like that Map is causing problems. I’m more of a Java/Python user so can’t help much.
but working fine on local.
now getting WA.lol
Check the for loop you have in your main() function, it should be:
for(int i=1;i<=n;i++)
You missed the equal sign.
i corrected the code,but WA is still,u got AC?
Not yet
4 WA…huh
we all are getting wa.i think file issue