DoorDash interview question

BFS problem and a string operation problem