Articulation Points Count
HardGraphDFSMathLinked List
Description
Given an undirected graph with n nodes (0..n-1) and an edge list, return the number of articulation points (nodes whose removal increases the number of connected components).
Examples
Input:
n = 5, edges = [[0,1],[1,2],[2,0],[1,3],[3,4]]Output:
2Explanation:
Removing node 1 or node 3 disconnects the graph; those are the two articulation points.
Input:
n = 4, edges = [[0,1],[1,2],[2,3]]Output:
2Explanation:
Nodes 1 and 2 lie on a path; removing either disconnects the graph, giving 2 articulation points.
Input:
n = 3, edges = [[0,1],[1,2],[2,0]]Output:
0Explanation:
A simple cycle has no articulation points, so the answer is 0.
Constraints
- •
1 ≤ n ≤ 1000 - •
0 ≤ edges.length ≤ 5000