Given an unweighted, connected graph and two nodes A and B, return the length of the shortest path between A and B, measured in number of edges. The graph is represented as an adjacency list, where graph[i] is the list of neighbors of node i.
Input
graph: adjacency list of the graph
A: starting node
B: destination node
Output
The minimum number of edges on any path from A to B.
Examples
Example 1
Inputgraph = [[1, 2], [0, 2, 3], [0, 1], [1]], A = 0, B = 3
Output2
Explanation: 0 -> 1 -> 3 uses two edges.
Constraints
Assume a path between A and B always exists.
1 <= number of nodes <= 10^4.