AKUNA CAPITAL interview question

The problem was about Breadth First Search algorithm.