Pergunta de entrevista da empresa Block

I was asked a BFS question (a common Leetcode problem).