Graph

Graph Representation

Adjacency Matrix

Adjacency List

There is some variation in the adjacency list representation. it may not necessarily as an array pointing to a list of children.

332. Reconstruct Itinerary

This problem requires we return the path that has the smallest lexical order. We could achieve that if every time we traverse the lexically smaller node first. How to do that? We could maintain a PriorityQueue / TreeSet over the node value. If no comparator is passed in, by default, it is lexically increasing order for string.

Map<String, PriorityQueue<String>> departArrivalMap = new HashMap<>();

results matching ""

    No results matching ""