Given an undirected graph with V vertices and E edges, check whether it contains any cycle or not. Graph is in the form of adjacency list where adj[i] contains all the nodes ith node is having edge ...
A sink is a vertex with no outgoing edges (out-degree = 0). 1. Find all vertices with out-degree 0 → add to Queue 2. Poll a sink from the Queue → removedCount++ 3. For each predecessor of that sink → ...