1086. Count Critical Nodes Whose Removal Disconnects Graph

HardGraphsSCCDFSGraph

Given an undirected graph with n nodes and edges, return the number of critical nodes (articulation points) — nodes whose removal increases the number of connected components. The input is JSON {n, edges}.

Input: JSON {n, edges}.

Output: Integer — the count of articulation points.

Examples

Example 1
Input: {"n":5,"edges":[[0,1],[1,2],[2,0],[1,3],[3,4]]}
Output: 2
Explanation: Nodes 1 and 3 are critical.
Example 2
Input: {"n":3,"edges":[[0,1],[1,2],[2,0]]}
Output: 0
Explanation: A cycle has none.
Example 3
Input: {"n":3,"edges":[[0,1],[1,2]]}
Output: 1
Explanation: The middle node is critical.

Constraints

Asked by

AmazonGoogleMicrosoftMetaAdobe
Solve this problem in the editor →