Bloomberg interview question

Graphs based question based on BFS, String formatting