Why am I getting TLE in my solution to a graph problem?


I used BFS on all nodes who haven’t been visited to find all connected components and their size. I see similar successful submissions to this question so why am I getting TLE?

vector<vector<int> > adj

Take this by reference instead of by value, as you have done with dist.


Thank you so much!

1 Like