Google interview question

It is a leetcode about BFS