Can you please explain the way to solve this problem

Ques:-https://practice.geeksforgeeks.org/problems/find-whether-path-exist5238/0/?track=DSASP-Graph&batchId=154