Google Interview Question

A recursive function + BFS