Mirantis interview question

Simple task about DFS