Google Cloud Interview Question

Question on bfs arranging arrays