Change the graph to use an adjacency list, rather than a 2D array, to improve space efficiency.
Change the graph to use an adjacency list, rather than a 2D array, to improve space efficiency.