You are given a directed graph with A vertices and M edges.
You are given an array B with dimensions M x 2, where each row denotes a directed edge from Bi, 0 to Bi, 1.
You need to find if there exists a mother vertex in the given graph. Return 1 if it exists, otherwise 0.
A mother vertex is defined as a vertex from which all the vertices in the graph are accessible by a directed path.
A = 3 B = [[1, 3], [2, 3], [1, 3]]
A = 3 B = [[1, 3], [2, 3], [3, 2]]
There is no vertex from which all the other vertices are accessible. Note there can be duplicate edges.
Vertex 1 is the mother vertex. We can reach 2 using 1 -> 3 -> 2. We can reach 3 using 1 -> 3
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a question? Checkout Sample Codes for more details.