Write edgesToAdjacencyList(n, edges, directed). The graph has nodes 0 to n - 1, and edges is an array of [u, v] pairs. Return an array of length n in which element i is the array of the neighbours of node i.
- If
directed is true, an edge [u, v] is stored only in u's list - Otherwise it is stored in both lists, and a self-loop
[u, u] is stored once in u's list - Neighbours appear in the order the edges are given. Parallel edges are kept, so
[0, 1] twice gives two entries - Nodes with no edges get an empty array, and every list must be its own array
- The input
edges must not be changed