05. Print adjacency list
Last updated
Was this helpful?
Last updated
Was this helpful?
The problem can be found at the following link:
A basic question with a direct approach:
I'm creating an adjacency list of a 2D vector to represent the graph.
I iterate through the given edges and push
them to the adjacency list, ensuring to push vertices from both directions since it's an undirected graph.
Time Complexity : O(E)
, where E
is the number of edges in the graph.
Auxiliary Space Complexity : O(V + E)
, where V
is the number of vertices and E
is the number of edges.
For discussions, questions, or doubts related to this solution, please visit our . We welcome your input and aim to foster a collaborative learning environment.
If you find this solution helpful, consider supporting us by giving a ⭐ star
to the repository.