Challenge: Check if a Path Exists Between Two Vertices

Given a graph and two vertices, can you write a code to check if a path exists between the two given vertices? Try it yourself!

Problem Statement #

In this problem, you have to implement checkPath() method to take a graph and two vertices as an input and find out if a path exists between them.

If there is no repeated sequence of edges and vertices between the source and the destination vertex then the path exists between these two vertices.

Note: Path will always exist if the source and destination nodes are the same.

An illustration is also provided below for your understanding:

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.