Reverse Graph
Given a directed graph represented as an adjacency list, return its reverse so if an edge goes from A to B, it now goes from B to A.
Each list in the adjacency list should be sorted in ascending order.
Constraints
0 ≤ n, m ≤ 250
wheren
is the number of rows andm
is the maximum number of columns ingraph
https://binarysearch.com/problems/Reverse-Graph
Examples
Example 1
Input
- graph =
[[1], [2], []]
Output
- answer =
[[], [0], [1]]
Explanation
In this example the nodes start off 0 -> 1 -> 2 and then become 0 <- 1 <- 2.
Leave a comment