HackerRank Interview Question

question on HashMap and Cycle Detection