n computers numbered 0 to n - 1. Some pairs are wired together: each links[i] = [u, v] is a cable between computers u and v that carries data both ways. Any two computers share at most one cable, and no cable loops back to the same computer.
Return True if a message can get from computer start to computer target, passing along cables through any computers in between, and False otherwise.n=5, links=[[0, 3], [3, 4], [1, 2]], start=0, target=4 → True
A message travels along 0 → 3 → 4.
n=5, links=[[0, 3], [3, 4], [1, 2]], start=4, target=2 → False
Computers 0, 3, 4 and computers 1, 2 form two separate groups with no cable between them.
n=2, links=[], start=1, target=1 → True
The start and the target are the same computer: the path is empty, but it exists.
n=5, links=[[0, 3], [3, 4], [1, 2]], start=0, target=4
True
Run checks the first 3 tests in your browser. Submit checks all 7 tests on the server, hidden ones included.