Solution: Implement Breadth-First Search
Explore how to implement breadth-first search (BFS) on a directed graph represented by an adjacency list. Understand how to traverse the graph level-by-level starting from a source vertex, manage visited nodes to prevent cycles, and return the traversal order. This lesson also covers the time and space complexity analysis of the BFS solution.
We'll cover the following...
We'll cover the following...
Statement
Given a directed graph represented as an adjacency list, graph, and an integer, source, which is the starting vertex number, return an array of integers, result, that contains the order of the graph’s breadth-first traversal starting from the source vertex.
Constraints:
graph.length...