948. Articulation point in graph

Given an undirected graph with V vertices and adjacency list adj. Find all the vertices removing which (and edges through it) would increase the number of connected components in the graph. The graph may be initially disconnected.. Return the vertices in ascending order. If there are no such vertices then returns a list containing -1.

Note: Indexing is zero-based i.e nodes numbering from (0 to V-1). There might be loops present in the graph.

Example 1:

Input: V = 7, adj=[[1,2,3], [0], [0,3,4,5], [2,0], [2,6], [2,6], [4,5]] 

Output: [0, 2]

Explanation: If we remove node 0 or node 2, the graph will be divided into 2 or more components.

Example 2:

Input: V = 5, adj=[[1], [0,4], [3,4], [2,4], [1,2,3]] 

Output: [1, 4]

Explanation: If we remove either node 1 or node 4, the graph breaks into multiple components.

Now Your Turn!

Pick the correct output for the given input

Input: V = 3, adj=[[1,2], [0,2], [0,1]]

Still unsure what the problem is asking ?

Let’s go through a few more examples, step by step, to make it clearer.

Constraints:

  • E= Number of Edges
  • 1 ≤ V, E ≤ 104

Hints

Frequently Occurring Doubts

Interview Follow-up Questions

Fun Facts

0
class Solution {
public:
vector<int> articulationPoints(int n, vector<int>adj[]) {
}
};
Test Case

Input:

Edges
N