Marks :10
: 1 | : 0
You are given a directed graph with $$$N$$$ vertices and $$$M$$$ edges.
You are given an array B with dimensions $$$M * 2$$$, where each row denotes a directed edge from $$$B[i][0]$$$ to $$$B[i][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.
The first line contains integers $$$N, M$$$. $$$1 \le N \le 5*10^5$$$ ,$$$1 \le M \le 10^6$$$.
The second line contains $$$M$$$ integers denoting the first row of Array $$$B.$$$, $$$1 \le B[i][0] \le N$$$
The third line contains $$$M$$$ integers denoting the second row of Array $$$B.$$$, $$$1 \le B[i][1] \le N$$$
Return a single integer 1 if a mother vertex exists, otherwise 0.
3 3 1 2 1 3 3 3
0
3 3 1 2 3 3 3 2
1
2 2 1 1 2 2
1
3 2 3 3 1 2
1
6 6 1 2 3 4 5 6 2 3 1 5 6 4
0
You need to login to view your submissions.
You need to login to view all submissions.
Result : Executed
Feel something is wrong with the test cases?
Result : Accepted
Test Cases :
But to Run or Submit the Problem, you need to Log In.
Continue to Log InYour challenge has been submitted successfully.
You will get a response soon via WhatsApp or Email.
Do let us know your issue.