Sentry (CA) interview question

Depth first search algo question