Challenge: Find "Mother Vertex" in a Directed Graph

Given a graph, can you find the Mother Vertex? Attempt to prove yourself!

Problem Statement #

🔍 Mother Vertex? #

A mother vertex in a graph G = (v,e) is a vertex v, such that all other vertices in G can be reached by a path from v.

In this problem, you have to implement the findMotherVertex() method to take a graph as an input and find out which vertex is the mother vertex in the graph. Remember, there’s no mother vertex in a disconnected graph. An illustration is also provided below for your understanding:

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