You are viewing a single comment's thread. Return to all comments →
can anyone explain why List of List is required? Can I store adjLst in array of LinkedList? like
LinkedList<Integer> adj[]; public Graph(int size) { this.size = size; adj = new LinkedList[size]; for(int i=0; i<size; i++) adj[i] = new LinkedList<>(); } public void addEdge(int first, int second) { adj[first].add(second); }
Seems like cookies are disabled on this browser, please enable them to open this website
BFS: Shortest Reach in a Graph
You are viewing a single comment's thread. Return to all comments →
can anyone explain why List of List is required? Can I store adjLst in array of LinkedList? like