On the Beach interview question

Online test at HackerRank about Graph algorithms