Ramp interview question

it was a bfs question