Salesforce interview question

BFS graphs