Soliton Technologies interview question

To program to solve a Graph problem in Hackerrank