One New Zealand interview question

question related to graph algorithm