Skip to content

Latest commit

 

History

History
7 lines (6 loc) · 294 Bytes

README.md

File metadata and controls

7 lines (6 loc) · 294 Bytes

bfs

We want to find if there is a path from the starting index to a element of value 0.
We can traverse the graph from the starting node. If we reach the the target element then we can terminate and return true.
Thus, we can do a bfs.

time: O(E + V) -> O(n)
space: O(V) -> O(n)